Hi everybody,
I am a little blocked with a loop I would like to do. I have the following code:
while($row=mysql_fetch_array($result)){
$bad_characters = array("&", "<", ">", "'", "\"");
$good_characters = array("&", "<", ">", "'", """);
$row[name] = str_replace($bad_characters, $good_characters, $row[name]);
$row[lastname] = str_replace($bad_characters, $good_characters, $row[lastname]);
//etc...
echo ‘blablalba’;
}
I would like to create a loop that would apply the str_replace function in every $row[] element, instead of applying the function one by one to $row[name], $row[lastname], etc..
I guess it would be something like:
foreach ($row as $key => $value){
$value = str_replace($bad_characters, $good_characters, $row[$value]);
}
Unfortunately, it doesn’t work.
Can anyone help me?
Thanks in advance,
Macsym