Current Benchmark
<?php
echo str_replace(
'Hi',
'Hello',
str_replace(
'u',
'you',
str_replace(
'r',
'are',
str_replace(
'2day',
'today',
'Hi, Jim, how r u 2day?'
)
)
)
);
?>
vs.
<?php
echo str_replace(
array (
'Hi',
'r',
'u',
'2day',
),
array (
'Hello',
'are',
'you',
'today',
),
'Hi, Jim, how r u 2day?'
);
?>
Conclusion
NOTE: I believe this test to be inconclusive, when taking into account margins of error. Times
also fluctuated between the two benchmarks every cycle.
After an average of 10000 cycles, the fastest option is Benchmark 2!
<?php
echo str_replace(
array (
'Hi',
'r',
'u',
'2day',
),
array (
'Hello',
'are',
'you',
'today',
),
'Hi, Jim, how r u 2day?'
);
?>