Re: RE: Printing structure and data of array

From: Date: Tue, 22 Jan 2002 14:59:35 +0000
Subject: Re: RE: Printing structure and data of array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-81552@lists.php.net to get a copy of this message
how about: <? $a = array("dit" => array("zus", "zo", "bla"), "nog" => array("wat", "van", "dit" => array("is", "dat")), "bla"); function displayarr($arr) { $c = ""; echo "array("; foreach($arr as $key => $val) { if($c) echo ", "; if(is_array($key)) displayarr($key); else echo "\"".$key."\" => "; if(is_array($val)) displayarr($val); else echo "\"".$val."\""; $c++; } echo ")"; } displayarr($a); ?> it prints the output just like you would enter it in your code... with kind regards, Joffrey van Wageningen ne2000.nl ----- Original Message ----- From: "Sandeep Murphy" <Sandeep.Murphy@oni.pt> To: "'Tim Ward'" <Tim.ward@stivesdirect.com>; "PHP List" <php-general@lists.php.net> Sent: Tuesday, January 22, 2002 3:41 PM Subject: RE: [PHP] RE: Printing structure and data of array > > nope... > > It continues to print in a single column indexed from 0 to .... It does not > print the sub elements as sub elements..... > > any more ideas??? > > regards, > sands > -----Original Message----- > From: Tim Ward [mailto:Tim.ward@stivesdirect.com] > Sent: terça-feira, 22 de Janeiro de 2002 12:56 > To: Sandeep Murphy; PHP List > Subject: RE: [PHP] RE: Printing structure and data of array > > > how about ... > > function ShowArray($array) > { echo("<ul>"); > foreach ($array as $key=>$value) > { echo("<li>$key") > if (is_array($value)) > { ShowArray($value); > } else > { echo("=>$value"); > } > echo("</li>") > } > echo("</ul>"); > } // end of fn ShowArray > > > Tim > www.chessish.com > > > -----Original Message----- > > From: Sandeep Murphy [SMTP:Sandeep.Murphy@oni.pt] > > Sent: 22 January 2002 12:01 > > To: 'Tim Ward'; PHP List > > Subject: RE: [PHP] RE: Printing structure and data of array > > > > hi, > > > > how can I display the array exactly as it is the format specified??? like > > if > > their exists sub elements of elements, how could I represent them in a > > multidimensional format?? > > > > I went thru most of the array functions but unable to adapt any of them.. > > > > pl help.. > > > > TIA, > > sands > > > > -----Original Message----- > > From: Tim Ward [mailto:Tim.ward@stivesdirect.com] > > Sent: segunda-feira, 21 de Janeiro de 2002 10:24 > > To: PHP List; Daniel Alsén > > Subject: [PHP] RE: Printing structure and data of array > > > > > > Foreach($array as $key=>$value) ech0("$key=>$value<br>"); > > > > Tim > > www.chessish.com <http://www.chessish.com> > > > > ---------- > > From: Daniel Alsén [SMTP:d@mindbash.com] > > Sent: 20 January 2002 19:33 > > To: PHP List > > Subject: Printing structure and data of array > > > > Hi, > > > > i know i have this answered before. But i can´t find that mail in > > the > > archive. > > > > How do i print an array to see both the structure and the data > > within? > > ("test" => "value", "test2" => "value2")... > > > > # Daniel Alsén | www.mindbash.com # > > # d@mindbash.com | +46 704 86 14 92 # > > # ICQ: 63006462 | +46 8 694 82 22 # > > # PGP: http://www.mindbash.com/pgp/ # > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#81552) next »