I\'m curious what the most performant method of doing string transformations is. Given a n input string and a set of translations, what method is the most efficient in gene
I made a trivial benchmark for personal needs on the two functions. The goal is to change a lowercase 'e' to an uppercase 'E'.
This code using str_replace runs in 6 seconds. Now the same with the strtr function :
It took only 4 seconds.
So as stated by T0xicCode, for this particularly simple case, strtr is indeed faster than str_replace, but the difference is not so significant.