I want to translate all the keys from the array that occur in this string:
$bar = "It gonna be tornado tomorrow and snow today.";
and replacing it with the value using this array:
$arr = array(
"tornado" => "kasırga",
"snow" => "kar"
);
So the output will be:
$bar = "It gonna be kasırga tomorrow and kar today.";
The function you’re looking for is called string-translate, written in it’s short form as
strtrDocs:Contrary to the popular belief in the other answers,
str_replaceis not safe to use as it re-replaces strings which is not what you want.