Oziam Posted November 9, 2010 Share Posted November 9, 2010 I want to replace an EXACT match only, I have been using str_replace but that seems to replace any part of a string containing the match. e.g $string = "Andora And Fortitude Of Official"; $result = str_replace(array("And", "Of"), array("and", "of"), $string)."\n"; will return "andora and fortitude of official"; but what I want is "Andora and Fortitude of Official" so it replaces only the EXACT match And, Of with and, of Thanks!.. Link to comment https://forums.phpfreaks.com/topic/218171-str_replace-exact-match-only/ Share on other sites More sharing options...
trq Posted November 9, 2010 Share Posted November 9, 2010 So you want.... $result = str_replace(array(" And ", " Of "), array(" and ", " of "), $string)."\n"; Link to comment https://forums.phpfreaks.com/topic/218171-str_replace-exact-match-only/#findComment-1132129 Share on other sites More sharing options...
Oziam Posted November 9, 2010 Author Share Posted November 9, 2010 LOL, your'e joking, I can't believe how simple that was! Of course it makes sense! Cheers! Link to comment https://forums.phpfreaks.com/topic/218171-str_replace-exact-match-only/#findComment-1132143 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.