Warning: Division by zero in /var/customers/webs/stc/benchmark/index.php on line 256 Test: str_ireplace vs. strtolower + str_replace

PHP Benchmarks

Performance comparison of PHP code alternatives.

Test: str_ireplace vs. strtolower + str_replace

Replace a string, regardless of its case, with an uppercase variant. 10 replacements in a 750 character line. str_replace/strtolower does not preserve existing case of the rest of the string.

Run Again Test Menu

Result

Unfortunately, no history for this test is available.

Code

The first test, "str_ireplace", was:

str_ireplace('sTrIng', 'STRING!', $GLOBALS['dummy']);

The second test, "str_replace/strtolower", was:

str_replace('string', 'STRING!', strtolower($GLOBALS['dummy']));

Running: Linux (x86_64:1 GB) PHP (7.2.25-1+ubuntu16.04.1+deb.sury.org+1)