note 33441 deleted from language.references by didou
| From: | didou@php.net | Date: | Thu, 26 Jun 2003 08:55:59 +0000 |
| Subject: | note 33441 deleted from language.references by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-51024@lists.php.net to get a copy of this message | ||
Note Submitter: gary@enova.com.tw; simon@enova.com.tw
----
I've created a simple function which could be used to refine $_POST array recursively, which
is done by passing by reference.
<?php
// Usage: refine($_POST);
// Strips whitespaces from the beginning and end of the input string.
// Strips slashesand HTML and PHP tags from the input string.
function refine(&$input) {
while (list($key, $val) = each($input)) {
if (!is_array($val)) {
$val = stripslashes(trim($val));
$val = strip_tags($val);
// do some work to refine data here...
$input[$key] = $val;
} else {
refine($input[$key]);
}
}
}
?>
Any suggestions and improvements will be welcomed.