Jump to content

[SOLVED] replacing special characters


purplenewt

Recommended Posts

hi I kind of know what I need to achieve here just not sure how to accomplish it. Basically I have a text box and when users type into it it doesnt seem to understand characters like pound signs and things, so to fix this problem i am thinking some code that basically does something like:

 

If £ found

replace £ with £

 

and then repeat that for several character types but im just not sure how to go about it.

 

Any help would be greatly appreciated, thanks.

 

Purplenewt

Link to comment
https://forums.phpfreaks.com/topic/125066-solved-replacing-special-characters/
Share on other sites

thanks a ton I followed the link you gave and found a better way to get the job done than I had thought of.

 

I was thinking I would have to do a lot of if else type coding for each character that wasn't displaying properly, on the link you gave me I found:

 

// Provides: You should eat pizza, beer, and ice cream every day
$phrase  = "You should eat fruits, vegetables, and fiber every day.";
$healthy = array("fruits", "vegetables", "fiber");
$yummy   = array("pizza", "beer", "ice cream");

$newphrase = str_replace($healthy, $yummy, $phrase);

 

which with a small amount of editing has saved me a ton of coding.

 

now I just have to find out how to mark this thread as solved:)

 

Thanks again

 

Purplenewt

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.