Hi
I've been trying to replace parts of strings in a results set, without much success. I've tried using str_replace() and eregi_replace() at about every location in the following code and the offending strings are still there.
I simply want to remove the – or ’ parts from any instance of $row[title] or $row[body] and replace them with " - " or " ' " respectively.
Where does the str_replace() go???
My code is below - any help is greatly appreciated!
// replace the offending string
function replace_string($string) {
$string = str_replace("–", "-", "$string");
$string = str_replace("’", "'", "$string");
}
// iterate through results array
if (mysql_num_rows($result) != 0) {
while ($row = mysql_fetch_array($result))
{
?>
// print HTML output
<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
}
?>