escape array?
Moderator: General Moderators
escape array?
I'm building an array through a loop,just a simple array... name[1], name[2], etc. How do you escape the contents of each array? mysql_escape_string won't work.
Code: Select all
How do you escape the contents of each arrayEasy to understand way:
Nice way (Good if you need to pass extra information to the callback function):
Alternative way (Good if you need to carry out the same thing on more than one array):
Code: Select all
for ($x=0;$x<count($arrMyArray);$x++) {
$arrMyArray[$x] = mysql_escape_string($arrMyArray[$x]);
}Code: Select all
array_walk($arrMyArray,"mysql_escape_string");Code: Select all
array_map("mysql_escape_string",$arrMyArray);Should be:onion2k wrote: Alternative way (Good if you need to carry out the same thing on more than one array):Code: Select all
array_map("mysql_escape_string",$arrMyArray);
Code: Select all
$arrMyArray = array_map("mysql_real_escape_string",$arrMyArray);Edit: better use mysql_real_escape_string, just to be more ... errr. .. real