 <p>Here's a recursive function that will indent:</p> <p>(<strong>Edited</strong>: Indentation wasn't working properly for all subelements, now it does)</p> <pre><code>function arrayPrettyPrint($arr, $level) { foreach($arr as $k =&gt; $v) { for($i = 0; $i &lt; $level; $i++) echo("&amp;nbsp;"); // You can change how you indent here if(!is_array($v)) echo($k . " =&gt; " . $v . "&lt;br/&gt;"); else { echo($k . " =&gt; &lt;br/&gt;"); arrayPrettyPrint($v, $level+1); } } } $arr = array( 1, 2, 3, array( 4, 5, array( 6, 7, array( 8 ))) ); arrayPrettyPrint($arr, 0); </code></pre>