note 47178 added to function.array-walk
| From: | php-general at lists dot php dot net | Date: | Fri, 05 Nov 2004 07:22:16 +0000 |
| Subject: | note 47178 added to function.array-walk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-80127@lists.php.net to get a copy of this message | ||
If array_walk_recursive() is not present and you want to apply htmlentities() on each array element
you can use this:
function array_htmlentities(&$elem)
{
if (!is_array($elem))
{
$elem=htmlentities($elem);
}
else
{
foreach ($elem as $key=>$value)
$elem[$key]=array_htmlentities($value);
}
return $elem;
} // array_htmlentities()
If you want to output an array with print_r() and you have html in it this function is very helpful.
----
Manual Page -- http://www.php.net/manual/en/function.array-walk.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47178
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47178&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47178&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47178&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47178&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47178&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47178&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47178&report=yes
Search -- http://master.php.net/manage/user-notes.php