setup print_r() look???

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

Post Reply
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

setup print_r() look???

Post by pedrotuga »

my print_r() output somtehing like this:

Code: Select all

Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 7 )
in the manual, and in code i see here and there it usually gives this:

Code: Select all

Array ( 
     [0] => 1 
     [1] => 2 
     [2] => 3 
     [3] => 7
 )
which is far so much easyer to read....
can i setup my conf somwhere so i have a similar result?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

either use

Code: Select all

echo '<pre>';
print_r($arrName);
echo '</pre>';
or

Code: Select all

echo nl2br(print_r($arrName, TRUE));
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I think many programmers use some variation of this:

Code: Select all

function dump($value, $label='') {
	echo $label . '<pre>' . print_r($value, 1) . '</pre>';
}
I tend to put it in the config.php file on the development site.
(#10850)
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

exactly :)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: setup print_r() look???

Post by Roja »

pedrotuga wrote:my print_r() output somtehing like this:

Code: Select all

Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 7 )
in the manual, and in code i see here and there it usually gives this:

Code: Select all

Array ( 
     [0] => 1 
     [1] => 2 
     [2] => 3 
     [3] => 7
 )
which is far so much easyer to read....
can i setup my conf somwhere so i have a similar result?
Actually, if you view source, it is outputting the latter. Your browser is the one mangling the output to look like the first one. :)
Post Reply