I have this loop that combines two arrays (questions and comments), i now want to escape it so i can use quotes and apostrophes in the comments fields.
$result = array();
foreach ($questions as $key => $value){
$value = mysqli_real_escape_string($value);
if (array_key_exists($key, $comments)){
$comments = mysqli_real_escape_string($comments);
$result[$key] = "$value~ {$comments[$key]}";
}else{
@$result[$key] = "$value~ ";
}
}
For some reason mysqli_real_escape_string is knocking out the values (leaving only the delimiter (~)).
I have tried array_map / array_walk with array_keys outside the loop but it has the same effect:
$comments = array_map("mysqli_real_escape_string", array_keys($comments));
mysql_real_escape_string() for entire $_REQUEST array, or need to loop through it?
i want to check array's data with mysql_real_escape_string() function
How do you escape an entire array with mysqli_real_ecape_string? Any help would be greatly appreciated!