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! 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 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... 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. 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); 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!!! Link to comment https://forums.phpfreaks.com/topic/146420-character-replace/#findComment-768757 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.