note 22364 deleted from ref.array by sniper

From: Date: Sat, 18 Oct 2003 18:04:31 +0000
Subject: note 22364 deleted from ref.array by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58845@lists.php.net to get a copy of this message
Note Submitter: spam (at) speedcapture . com ---- I want to share a VERY usefull way to debug php and arrays: just create a file like array.func.inc.php paste the following code into the file. // To make ANY array visible ... function viewArray($arr) { echo '<table cellpadding="0" cellspacing="0" border="1">'; foreach ($arr as $key1 => $elem1) { echo '<tr>'; echo '<td>'.$key1.'&nbsp;</td>'; if (is_array($elem1)) { extArray($elem1); } else { echo '<td>'.$elem1.'&nbsp;</td>'; } echo '</tr>'; } echo '</table>'; } function extArray($arr) { echo '<td>'; echo '<table cellpadding="0" cellspacing="0" border="1">'; foreach ($arr as $key => $elem) { echo '<tr>'; echo '<td>'.$key.'&nbsp;</td>'; if (is_array($elem)) { extArray($elem); } else { echo '<td>'.htmlspecialchars($elem).'&nbsp;</td>'; } echo '</tr>'; } echo '</table>'; echo '</td>'; } close the file and include that file into any other php document. If u want to check the content of an array just type viewarray($array);

« previous php.notes (#58845) next »