Print_r: A Very Useful PHP Function
Sunday, July 27th, 2008Have you ever had an array or object returned by a PHP function, but you didn’t know how it was structured? In order to proceed writing your code, you would need to known what’s in the array, and how to access it. This somes up if you use XML-based APIs a lot, or if you’re dealing with WordPress’s $wpdb class.
That’s where the useful print_r function comes in.
Print_r is implemented simply by calling it, and passing a variable as an argument. The variable you should pass would be your array or object. Also, you need to surround it in <pre> tags (unless you want a jumbled mess that will be hard to read).
echo '<pre>';
print_r($the_variable);
echo '</pre>';
Simple enough, and insanely useful.


Yahoo recently released a new search API. Known as
Looking for a way to feature some of your better posts? Here’s a method I’ve been using for a few months (visible on the
Tired of the bloated Coppermine Photo Gallery? The much lighter 







