I'm trying to replace any occurances of previously converted characters, i.e. changing – to "-" within a results page.
I want to apply the str_replace function to each array just before it is printed. I have tried two different approaches (by the book I think) and still no joy.
Anyone with any ideas why this isn't working please help!!!
function replace_string($string) {
$string = str_replace("–", "-", "$string");
$string = str_replace("’", "'", "$string");
return($string);
}
if (mysql_num_rows($result) != 0) {
while ($row = mysql_fetch_array($result)){
array_walk ($row, 'replace_string');
reset ($row); TRIED THIS WAY
$row[title] = replace_string(&$row[title]); TRIED THIS ALSO
$row[body] = replace_string(&$row[body]);
?>
<p><font face="Arial, Helvetica, sans-serif" size="-1" color="#000000">
<font color="#978B7F"><php print $row[title]; ?></b></a><br>
<font color="#000000"><?php print substr($row[body],0,70) ." . . ."; ?><br>
<i><?php print "$row[article_date]"; ?></i></font></font></font></p>
<?php
}
}