How often have you felt the need to display a PHP Object in a readable manner? We are all very familiar with the use of the print_r() function. However, print_r() gives a difficult to read output and we end up matching braces to figure out the exact structure of complex objects. Here is a small trick which you can use to see the print_r() output in a 'Display for Humans' format.
echo '<pre>';
print_r($object);
echo '</pre>';
Let's see an example(borrowed from PHP.net):
<pre>
<?php
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print_r ($a);
?>
</pre>
The output will be:
Array
(
[a] => apple
[b] => banana
[c] => Array
(
[0] => x
[1] => y
[2] => z
)
)
Enjoy!
Technologies: