note 28609 added to function.array-walk
| From: | dakota at tensen dot net | Date: | Fri, 17 Jan 2003 22:14:51 +0000 |
| Subject: | note 28609 added to function.array-walk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42301@lists.php.net to get a copy of this message | ||
I have often found it helpful in form post situations to be able to view all of the values that have
been submitted by the form to make sure that they are being sent right. I used to have a page that
did this but I then realized that I could make a function out of it. So I did this and then I
realized I could make this take any array variable and so I made it recursive and so it shows
everything inside an array, perhaps like the 'array_walk()' function but I never could get
that to work.
function view_values($VARS)
{
$row = 0;
echo("<table>");
while (list ($key, $val) = each ($VARS))
{
echo ("<tr bgcolor=#" . (($row/2) == floor($row/2) ? "444444" :
"666666") . "><td>$key</td><td>");
if(!is_array($val))
echo("$val</td></tr>\n");
else
echo(view_values($val));
$row++;
}
echo("</table>");
}
--
http://www.php.net/manual/en/function.array-walk.php
http://master.php.net/manage/user-notes.php?action=edit+28609
http://master.php.net/manage/user-notes.php?action=delete+28609
http://master.php.net/manage/user-notes.php?action=reject+28609