Re: Re: regarding print_r()
| From: | Ken Robinson | Date: | Sun, 10 Nov 2013 14:15:46 +0000 |
| Subject: | Re: Re: regarding print_r() | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322445@lists.php.net to get a copy of this message | ||
A nice application of the second parameter is to get the output of print_r formatted on your web page:
echo '<pre>' . print_r($ary, true) . '</pre>';
much easier to read...
Ken
At 08:26 AM 11/10/2013, Sachin Raut wrote:
Thank you Mr.Sperberg for telling about 2nd parameter. Really appreciate your help. Thanks Sachin Raut On Sun, Nov 10, 2013 at 2:39 PM, Camilo Sperberg <unreal4u@gmail.com> wrote: On 10 nov. 2013, at 06:24, Sachin Raut <imsachinraut@gmail.com> wrote:Issue resolved. I didn't notice that i was passing print_r() function to echo. Silly mistake. Thanks Sachin Raut On Sun, Nov 10, 2013 at 10:39 AM, Sachin Raut <imsachinraut@gmail.com wrote:here orHello, I am trying to print following array using print_r(), but it appends number "1" to the output. Can someone pls tell me what is the issueI think everyone on this list has made that same mistake once. Just as a sidenote, you can pass true as second parameter to have print_r return the contents instead of printing them directly. It comes in very handy in case you need to escape characters before printing or manipulate the string before you want to print. Greetings. Met vriendelijke groet, Camilo Sperberg ---------------- W: http://unreal4u.com T: http://twitter.com/unreal4uis there any setting i need to do in PHP. Thanks Sachin Raut <?php $a[]="Paris"; $a[]="London"; echo print_r($a); ?> Output : Array ( [0] => Paris [1] => London ) 1