PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
neel_basu
Forum Contributor
Posts: 454 Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India
Post
by neel_basu » Wed Jan 10, 2007 1:06 pm
I am Using php 5
and Using print_r() But Its Is Showing the results in 1 line
Code: Select all
<?php
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
print_r ($a);
?>
The above code make output
Code: Select all
Array ( [a] => apple [b] => banana [c] => Array ( [0] => x [1] => y [2] => z ) )
But it should output like this ( according to manual )
Code: Select all
Array
(
[a] => apple
[b] => banana
[c] => Array
(
[0] => x
[1] => y
[2] => z
)
)
How can I solve It ??
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Wed Jan 10, 2007 1:11 pm
neel_basu
Forum Contributor
Posts: 454 Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India
Post
by neel_basu » Wed Jan 10, 2007 1:13 pm
AKA Panama Jack wrote: You could try...
Thanks Now I Got It
i see
The print_r function is not Using <br /> it is Using \n and \t
Thanks For Your Replies
Kieran Huggins
DevNet Master
Posts: 3635 Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:
Post
by Kieran Huggins » Wed Jan 10, 2007 1:16 pm
I usually use the large, nasty:
Code: Select all
echo '<pre>';
print_r($a);
echo '</pre>';
It's not sexy, but it works!
I guess you could write your own debugging shorthand functions and include them while you develop, like:
Code: Select all
function pre_print_r($var){
echo '<pre>';
print_r($var);
echo '</pre>';
}