note 52361 added to function.htmlspecialchars
| From: | gtatrealvertex dot com at osu1 dot php dot net | Date: | Thu, 28 Apr 2005 16:55:40 +0000 |
| Subject: | note 52361 added to function.htmlspecialchars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88705@lists.php.net to get a copy of this message | ||
Here is the recursive version that works for both arrays and strings. Doesn't look as elegant
as the other recursive versions, because of the input checks.
function HTML_ESC($_input = null, $_esc_keys = false)
{
if ((null != $_input) && (is_array($_input)))
{
foreach($_input as $key => $value)
{
if($_esc_keys)
{
$_return[htmlspecialchars($key)] = HTML_ESC($value,$_esc_keys);
}
else
{
$_return[$key] = HTML_ESC($value);
}
}
return $_return;
}
elseif(null != $_input)
{
return htmlspecialchars($_input);
}
else
{
return null;
}
}
----
Manual Page -- http://www.php.net/manual/en/function.htmlspecialchars.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52361
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52361&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52361&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52361&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52361&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52361&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52361&report=yes
Search -- http://master.php.net/manage/user-notes.php