note 55312 deleted from function.is-numeric by cmb
| From: | cmb@php.net | Date: | Sun, 23 Jun 2019 10:32:02 +0000 |
| Subject: | note 55312 deleted from function.is-numeric by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211345@lists.php.net to get a copy of this message | ||
Note Submitter: maninblack00 at mail dot ru
----
blazatek at wp dot pl wrote a function to check POST inputs for ASCII-keys or smth like that. there
was an error while filtering $varvalue (it was only the value of the last filter
'addslashes')
here's the corrected function:
<?
function is_num ($num) {
// .....
}
function test_post($tab) {
$post = array();
$post = $tab;
foreach ($post as $varname => $varvalue) {
echo $tab[$varname];
if (empty($varvalue)) {
$post[$varname] = null;
}
elseif (is_num($varvalue)) {
$varvalue=trim($varvalue);
$varvalue=strip_tags($varvalue);
$varvalue=intval($varvalue);
$post[$varname]=addslashes($varvalue);
}
else {
$post[$varname]=NULL;
}
}//forech
return $post;
}
?>
hope that correction is correct ;)