note 49998 added to ref.array
| From: | max at caconsultant dot com | Date: | Tue, 15 Feb 2005 01:09:23 +0000 |
| Subject: | note 49998 added to ref.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85040@lists.php.net to get a copy of this message | ||
The following recusive function can dump the contents of an array. I wrote it to help debug HTML
form. Enjoy!
function dump_array($array, $name) {
foreach ($array as $key => $value) {
if (is_integer($key)) $keyName = $key; else $keyName = "'$key'";
if (is_array($value)) {
$newName = $name . "[$keyName]";
dump_array($value, $newName);
} else {
print "{$name}[$keyName] => $value";
print "<br />";
}
}
}
Usage Example:
dump_array($_POST, '$_POST');
Please note that do NOT use " to quote the $_POST.
----
Manual Page -- http://www.php.net/manual/en/ref.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49998
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49998&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49998&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49998&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49998&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49998&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49998&report=yes
Search -- http://master.php.net/manage/user-notes.php