note 103001 deleted from function.array-map by danbrown
| From: | danbrown@php.net | Date: | Sat, 19 Mar 2011 15:23:57 +0000 |
| Subject: | note 103001 deleted from function.array-map by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-178009@lists.php.net to get a copy of this message | ||
Note Submitter: Solenoid
----
A little neater way to do recursion:
<?php
// I needed my input cleaned
function clean(&$input)
{
if(is_array($input))
{
$input = array_map('clean', $input);
}
else
{
$input = mysql_real_escape_string($input);
}
}
?>
It can also be used inside a class as a method, just replace array_map('clean', $input);
with array_map(array($this, 'clean'), $input);