3v4l.org

run code in 300+ PHP versions simultaneously
<?php/** * Compare building an array an in_array()ing it, vs a regex check */$runs = 1000000;// in_array$t = microtime(true);for ($i = 0; $i < $runs; $i++) { if (in_array('test', ['foo','bar','baz','fooby','bario','xyz','abc','def','ghi','jkl','mno','pqr','stu','vwx']));}$t -= microtime(true);echo 'in_array: ', $t, PHP_EOL;// preg_match$t = microtime(true);for ($i = 0; $i < $runs; $i++) { if (preg_match('/^(foo|bar|baz|fooby|bario|xyz|abc|def|ghi|jkl|mno|pqr|stu|vwx)$/', 'test'));}$t -= microtime(true);echo 'preg_match: ', $t, PHP_EOL;<?php
Output for git.master, git.master_jit, rfc.property-hooks
<?php/** * Compare building an array an in_array()ing it, vs a regex check */$runs = 1000000;// in_array$t = microtime(true);for ($i = 0; $i < $runs; $i++) { if (in_array('test', ['foo','bar','baz','fooby','bario','xyz','abc','def','ghi','jkl','mno','pqr','stu','vwx']));}$t -= microtime(true);echo 'in_array: ', $t, PHP_EOL;// preg_match$t = microtime(true);for ($i = 0; $i < $runs; $i++) { if (preg_match('/^(foo|bar|baz|fooby|bario|xyz|abc|def|ghi|jkl|mno|pqr|stu|vwx)$/', 'test'));}$t -= microtime(true);echo 'preg_match: ', $t, PHP_EOL;

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
38.05 ms | 402 KiB | 8 Q