Jump to content

str_replace EXACT match only


Oziam

Recommended Posts

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

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.