Narafir Posted February 22, 2009 Share Posted February 22, 2009 Hello!!! Some help with the following? I have a paragraph of text in $mytext. How can i read every character and if the current character is e.g. "E" to replace it with "W" etc? Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/146420-character-replace/ Share on other sites More sharing options...
Mchl Posted February 22, 2009 Share Posted February 22, 2009 str_replace Quote Link to comment https://forums.phpfreaks.com/topic/146420-character-replace/#findComment-768725 Share on other sites More sharing options...
Narafir Posted February 22, 2009 Author Share Posted February 22, 2009 Thank you for your quick answer... But what can i do if i need to make several changes? example: $myText. (a short paragraph) Read each character: case A: //if the character is A change A to B //change char a to char B case F: change F to G etc etc... Quote Link to comment https://forums.phpfreaks.com/topic/146420-character-replace/#findComment-768730 Share on other sites More sharing options...
Mchl Posted February 22, 2009 Share Posted February 22, 2009 Read the manual. Take a look at examples. It's all there. Quote Link to comment https://forums.phpfreaks.com/topic/146420-character-replace/#findComment-768735 Share on other sites More sharing options...
.josh Posted February 22, 2009 Share Posted February 22, 2009 $letters['old'] = array('A','F'); $letters['new'] = array('B','G'); $myText = str_replace($letters['old'], $letters['new'], $myText); Quote Link to comment https://forums.phpfreaks.com/topic/146420-character-replace/#findComment-768743 Share on other sites More sharing options...
Narafir Posted February 22, 2009 Author Share Posted February 22, 2009 Thank you very much!!! Quote Link to comment https://forums.phpfreaks.com/topic/146420-character-replace/#findComment-768757 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.