Translating character codes (i think)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mintedjo
Forum Contributor
Posts: 153
Joined: Wed Nov 19, 2008 6:23 am

Translating character codes (i think)

Post 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"
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Translating character codes (i think)

Post by php_east »

Code: Select all

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

Code: Select all

£123
mintedjo
Forum Contributor
Posts: 153
Joined: Wed Nov 19, 2008 6:23 am

Re: Translating character codes (i think)

Post 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!
mintedjo
Forum Contributor
Posts: 153
Joined: Wed Nov 19, 2008 6:23 am

Re: Translating character codes (i think)

Post 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!
Post Reply