3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input = '1|27|31|33'; $separator = '##|##'; $iterations = 1000000; $time = microtime(true); var_dump($time); for ($i = 0; $i < $iterations; $i++) { $result = str_replace('|', $separator, $input); } $time1 = microtime(true); echo 'processed in ' . (($time1 - $time) * 1000) . ' millisecs'); for ($i = 0; $i < $iterations; $i++) { $result = ''; $it = new CachingIterator(new ArrayIterator(explode('|', $input)), CachingIterator::FULL_CACHE); foreach ($it as $categoryId) { $result .= $categoryId; if ($it->hasNext()) { $result .= $separator; } } } $time2 = microtime(true); echo 'processed in ' . (($time2 - $time1) * 1000) . ' millisecs');
Output for 5.3.0 - 5.4.21
Parse error: syntax error, unexpected ')', expecting ',' or ';' in /in/4BFHm on line 12
Process exited with code 255.