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!.. Quote 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"; Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.