Tags: php

How to use PHP print_r() Function

This PHP Tutorial will give you some information about “PHP print_r() function”, which includes Syntax, Examples, Usage and output. The print_r() will print any array including multidimensional Arrays. The return parameter will let you capture the output of print_r(). When this parameter is set to TRUE, print_r() will return the information rather than print it.

Syntax

mixed print_r ( mixed $expression [, bool $return = false ] )

PHP print_r() Function

 'Certification ',
               'b' => 'Paths', 
               'c' => array ('ccna', 'ccnp', 'ccie'));
print_r ($myar);
?>

Output

Array
(
    [a] => This php code
    [b] =>  is written by 
    [c] => Array
        (
            [0] => noob
            [1] => prof
            [2] => expert
        )

)

Return Statement
Or you can use another variable to store output from print_r and later echo it to get the above output again.
$results = print_r($myar, true);
echo $results;


  1. Sudipto says:

    Hi from my end,

    I liked your site: “ispsd.com”. Can we email about a proposition with your site? This is regarding a posting in your site. I can surely render certain benefits to you.

    Looking for your reply.

    Regards,
    Sudipto

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>