PHP print variables in human readable form with print_r 

Joined:
03/10/2011
Posts:
84

March 10, 2011 12:14:50    Last update: March 10, 2011 12:15:52
Use print_r to print out variables in human readable form.
<?php
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print("Plain print:\n============\n$a\n\n");

print "print_r:\n========\n";
print_r ($a);
?>


Prints:
Plain print:
============
Array

print_r:
========
Array
(
    [a] => apple
    [b] => banana
    [c] => Array
        (
            [0] => x
            [1] => y
            [2] => z
        )

)

Share |
| Comment  | Tags