note 75948 modified in function.strip-tags by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 15:57:43 +0000 |
| Subject: | note 75948 modified in function.strip-tags by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154724@lists.php.net to get a copy of this message | ||
This is an upgrade to the illegal characters script by rodt [on 16-JAN-07]. This script will handle
the input, even if the one or all of the fileds include arrays. Of course another loop could be
added to handle compound arrays within arrays, but if you are savvy enough to be using compound
arrays, you don't need me to rewrite the program.
<?php
function screenForm($ary_check_for_html)
{
// check array - reject if any content contains HTML.
foreach($ary_check_for_html as $field_value)
{
if(is_array($field_value))
{
foreach($field_value as $field_array) // if the field value is an array, step through it
{
$stripped = strip_tags($field_array);
if($field_array!=$stripped)
{
// something in the field value was HTML
return false;
}
}
}else{
$stripped = strip_tags($field_value);
if($field_value!=$stripped)
{
// something in the field value was HTML
return false;
}
}
}
return true;
}
?>
--was--
This is an upgrade to the illegal characters script by robt. This script will handle the input, even
if the one or all of the fileds include arrays. Of course another loop could be added to handle
compound arrays within arrays, but if you are savvy enough to be using compound arrays, you
don't need me to rewrite the program.
<?php
function screenForm($ary_check_for_html)
{
// check array - reject if any content contains HTML.
foreach($ary_check_for_html as $field_value)
{
if(is_array($field_value))
{
foreach($field_value as $field_array) // if the field value is an array, step through it
{
$stripped = strip_tags($field_array);
if($field_array!=$stripped)
{
// something in the field value was HTML
return false;
}
}
}else{
$stripped = strip_tags($field_value);
if($field_value!=$stripped)
{
// something in the field value was HTML
return false;
}
}
}
return true;
}
?>
http://php.net/manual/en/function.strip-tags.php