0

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?

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by CarterLangley
0

Hi,

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;

Edited by veedeoo: more info. added

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.