PDA

View Full Version : str_replace ° to °



Joe!
27-04-2010, 05:45 PM
Now I had this working a few weeks ago but something must have changed and now it no longer works.
Here's my code, if someone could help me out and spot any errors or give advice, that would be brilliant :)

$pos1[1] = str_replace("°","°",$pos1[1]);
echo $pos1[1];

Apolva
28-04-2010, 05:36 PM
It works fine for me, no problems when I add this to the beginning:


$pos1[1]="Hey, it's 7°C";


You might want to consider using the htmlentities() function to replace all special characters with their HTML equivalents, eg.


$pos1[1]=htmlentities($pos1[1]);

Agnostic Bear
28-04-2010, 05:37 PM
Right click > View source.

Joe!
28-04-2010, 10:31 PM
Thanks for that Apolva, don't know why I didn't just do that in the first place :(
Working now anyway, now to convert the degrees minutes seconds into decimals.. fun :)
@Jewish Bear, heh heh.

Want to hide these adverts? Register an account for free!