I was looking at how the
str_replace functions behaved and I noticed that, at first glance, the two seem to do exactly the same thing.
$translators = [ 'da hora' => 'bacana', 'ser' => 'é', ]; $str = 'O Stack Overflow ser um site da hora'; echo str_replace(array_keys($translators), $translators, $str); // O Stack Overflow é um site bacana echo strtr($str, $translators); //O Stack Overflow é um site bacana
By taking the way the function parameters are passed, are there any significant differences between them, so that you have to decide which one to use for each specific case?
Or do they both do the same thing?
And if they do, why should the two exist?