开发者

Alternate way for string replace and array

开发者 https://www.devze.com 2022-12-28 05:30 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号