note 50028 deleted from function.print-r by nlopess

From: Date: Thu, 14 Apr 2005 15:35:27 +0000
Subject: note 50028 deleted from function.print-r by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-88013@lists.php.net to get a copy of this message
Note Submitter: ---- Here is a general function that recursively walks any array, and displays the contents in a nice way: <?php function walk($prefix, $array) { if (is_array($array)) foreach ($array as $key=>$val) walk($prefix."[".$key."]",$val); else echo "$prefix=$array;<BR>\n"; } ?> For example: <?php $test = array('a'=>'Aa', 'b'=>array('Bb'=>'Ccc'), 'd'=>array('Ee'=>array('Fff'=>'Gggg')) ); walk('$test', $test); // Ouput: /* $test[a]=Aa; $test[b][Bb]=Ccc; $test[d][Ee][Fff]=Gggg; */ ?>

« previous php.notes (#88013) next »