This has got me very confused. Here is the code but it is not doing what it should do!!

echo "<span class='vehicle_table_normal'>";$str_bodystyle=str_replace("," ,"<br />",$bodystyle);$str_bodystyle=str_replace("-" ,"&#45; ",$bodystyle);$str_bodystyle=str_replace(" - " ," &#45; ",$bodystyle);echo $str_bodystyle;

The first replace is the most important for display purposes at this moment. The next two are because I like things to look the same. but none of the three replaces are doing anything!

What on earth am I doing wrong?


The problem with the codes are your variable names they are all the same. The script will only show the very last one, because it will override the first two. If you want it to work, then use .= (concatenating assignment operator) .

something like this..

$str_bodystyle = ""; //prevent any errors in php 5.3 and above.

$str_bodystyle .= str_replace("," ,"<br/>",$bodystyle);
$str_bodystyle .=str_replace("-" ,"&#45; ",$bodystyle);
$str_bodystyle .=str_replace(" - " ," &#45; ",$bodystyle);
echo $str_bodystyle;