Debugging an Array – Print it Recursively with print_r()

Last Updated on: October 27, 2010

Nice and simple one..

If you want to see whats in an entire array, use the print_r function. This will give you a nicely formatted output of the array showing all dimensions. Try it:
{code type=php}$anArray = array(0=>’cheese’,1=>’bacon’,2=>’apples’);
print_r($anArray); {/code}

Tip if you are viewing this via the output of a webpage, view the source to see the nicely formatted output or wrap the output in pre tags e.g.

{code type=php}


{/code}


Get notified of new posts:


Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *