Alternate way for string replace and array
Is there any way to replace titles faster then str_replace function? I've got a file that is 20开发者_C百科00 lines of array changes. That hurts my webpage.
In short... no. It doesn't get much faster than str_replace when it comes to replacing text. I don't know where this data is coming from, but I'd suggest changing your application to do this only once and then store the result somewhere. On subsequent request just return the transformed data.
It's either that or upgrading the machine this runs on.
For that number of replacements, you will see considerable performance loss if you are calling str_replace
for each replacement. Calling it once with an array of the before and after is much faster.
精彩评论