Archive for December, 2007 Page 4 of 4



[Yoroshiku] Kekkaishi - 39 1024×576 H264

Kekkaishi - 39 1024×576 H264

If you liked this post, please subscribe to my feed. Thanks for visiting!

[Yoroshiku] Kekkaishi - 38 1024×576 H264

Kekkaishi - 38 1024×576 H264

[Conclave-Mendoi] Mobile Suit Gundam 00 - 09 1280×720 H.264 AAC

Mobile Suit Gundam 00 - 09 1280×720 H.264 AAC

[A-E & Saizen] Shigurui - 07

Shigurui - 07

[Yoroshiku] Kekkaishi 36-37 1024×576 H264

Kekkaishi 36-37 (1024×576 H264)

PHP: speed of string replacement functions

What is the fastest string replacement function in PHP? sprintf() is probably the fastest, but it’s only useful in limited situations where the input is prepared for sprintf formatting. preg_replace() is obviously the slowest. The big debate is whether str_replace() or strtr() is faster.

The lixlpixel PHP benchmarks show that strtr is the faster of the two. I then came across Simple Machine’s benchmarks which show that str_replace() is faster. Hmm what’s going on?

Syridium DV’s PHP benchmarks performs more varied tests with these two functions. The relative speed of these two functions might vary depending on the type of string replacement you are performing. However, it seems that str_replace() is usually a safe bet.