note 103001 added to function.array-map
| From: | Solenoid at osu1 dot php dot net | Date: | Sat, 19 Mar 2011 13:20:38 +0000 |
| Subject: | note 103001 added to function.array-map | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178002@lists.php.net to get a copy of this message | ||
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);
----
Server IP: 69.147.83.197
Probable Submitter: 46.126.143.42
----
Manual Page -- http://www.php.net/manual/en/function.array-map.php
Edit -- https://master.php.net/note/edit/103001
Del: integrated -- https://master.php.net/note/delete/103001/integrated
Del: useless -- https://master.php.net/note/delete/103001/useless
Del: bad code -- https://master.php.net/note/delete/103001/bad+code
Del: spam -- https://master.php.net/note/delete/103001/spam
Del: non-english -- https://master.php.net/note/delete/103001/non-english
Del: in docs -- https://master.php.net/note/delete/103001/in+docs
Del: other reasons-- https://master.php.net/note/delete/103001
Reject -- https://master.php.net/note/reject/103001
Search -- https://master.php.net/manage/user-notes.php