note 10684 added to each

From: Date: Wed, 17 Jan 2001 03:35:35 +0000
Subject: note 10684 added to each
Groups: php.notes 
Request: Send a blank email to php-notes+get-9872@lists.php.net to get a copy of this message
I use this as a debugging function, it prints out an entire array (all it's dimentions too!) function ListArray($var, $title='ListArray') { if($title){ $string = ''; } $string .= '<table border="0" cellpadding="2" cellspacing="1" bgcolor="CCCCCC" style="font-size: 10px;">'; if($title){ $string .= '<tr bgcolor="003346" style="color: whitesmoke;"><td><b>Key</b></td><td><b>Value</b></td></tr>'; } while(list($key, $val) = each($var)) { $string .= '<tr bgcolor="whitesmoke">' ; $string .= "<td valign=\"top\"><b>$key</b></td><td valign=\"top\">"; if(is_array($val)){ $string .= ListArray($val, ''); }else{ $string .= "$val" ; } $string .= '</td></tr>'; }//While $string .= "</table>"; if($title){ $string .= ''; } return $string; } $TheArray[1] = 'foo'; $TheArray['bob']] = 'is cool'; ListArray($TheArray); http://www.php.net/manual/en/function.each.php

« previous php.notes (#9872) next »