0

Is there any way to replace titles faster then str_replace function? I've got a file that is 2000 lines of array changes. That hurts my webpage.

2
  • One time? Every time your page loads? More specifics would be helpful. Commented Apr 21, 2010 at 23:00
  • @manos I'm replacing bad words in table listing Commented Apr 21, 2010 at 23:07

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.