I would like to know how I can replace exactly words in PHP
, I currently have this:
$string = "Despues de tomar no maneje, es mejor llamar un taxi";
$exceptions = array(
"de" => "DE",
"es" => "ES"
);
$conver = str_replace(array_keys($exceptions), $exceptions, $string);
//OUTPUT: DEspuES DE tomar no maneje, ES mejor llamar un taxi
What I want is for it to change only if the word matches and not in all the characters it finds:
Ahem:
After DO NOT drive, it is better to call a taxi