Page 1 of 1

Translating character codes (i think)

Posted: Wed Apr 15, 2009 11:15 am
by mintedjo
*to the tune of I have a dream by abba*
I have a string
It's being gay
It has some chars, that won't display
*end*
How can I convert these things in my string to pound symbols? I've spent ages looking for things and trying random stuff but I guess i just fail :-(
$str = "£0.01 - £2.50";
That string should read "£0.01 - £2.50"

Re: Translating character codes (i think)

Posted: Wed Apr 15, 2009 11:34 am
by php_east

Code: Select all

$str = '£'.'123';
echo $str;
 

Code: Select all

£123

Re: Translating character codes (i think)

Posted: Wed Apr 15, 2009 11:42 am
by mintedjo
THAT'S THE BEST SOLUTION TO ANYTHING I'VE EVER SEEN, EVER!
No seriously... how can I change my original string so taht the character code thingies become '£'?
I was hoping there was a standard method so that any other characters that cause this problem would be dealt with in the same way but if not i`ll just have to do a replace and add other characters later if it comes up... :-\
Honestly though... GOOD ANSWER!

Re: Translating character codes (i think)

Posted: Thu Apr 16, 2009 4:15 am
by mintedjo
Apparently yes that's waht I was looking for, although it's turned out to be the wrong way to fix this thing and is still causing problems.
Thanks though!