Skip to content

print_r ​

php
mixed print_r(mixed $arg, [bool $return])

The print_r() function is equivalent to PHP's function of the same name. Displays the argument in a readable form, for example the contents of an entire array, whereas print() would require selecting a specific index. Primarily useful for debugging scripts.

If the optional second argument is true, returns the formatted output instead of displaying it. Otherwise the function always returns true.

Example:

php
$array = array(1,2,3);
print_r($array);

The result is:

Array
(
[0] => 1
[1] => 2
[2] => 3
)