Reply to Re: pretty_print meets var_dump() ?

Your name:

Reply:


Posted by Andy Hassall on 12/20/05 12:37

On 20 Dec 2005 02:13:10 -0800, "Baron Samedi" <Papa.Legba.666@gmail.com> wrote:

>I have some pretty hairy arrays and when I var_dump() I get an
>unreadable mess.
>
>Surely someone has already written a function which will take a
>var_dump and structure it?
>
>Does it already exist, or do I have to code it myself?

There's print_r which might be more to your taste.

Also see the user-contributed notes on the print_r page in the PHP online
manual.

You are surrounding the var_dump() with <pre></pre> tags, right? Because
var_dump does structure nested arrays in a very similar way to your diagram
anyway.

<?php
$a = array('a' => array('b', array('c', array('d'))));
print "<pre>";
var_dump($a);
print_r($a);
var_export($a);
print "</pre>";
?>

Output:

array(1) {
["a"]=>
array(2) {
[0]=>
string(1) "b"
[1]=>
array(2) {
[0]=>
string(1) "c"
[1]=>
array(1) {
[0]=>
string(1) "d"
}
}
}
}
Array
(
[a] => Array
(
[0] => b
[1] => Array
(
[0] => c
[1] => Array
(
[0] => d
)

)

)

)
array (
'a' =>
array (
0 => 'b',
1 =>
array (
0 => 'c',
1 =>
array (
0 => 'd',
),
),
),
)

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация