3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startTime = microtime(true); for($i=0; $i<100000; $i++) { $foo = "foo"; $bar = "bar"; $baz = "baz"; $array = compact('foo','bar','baz'); } $endTime = microtime(true); $elapsed = $endTime - $startTime; echo "With compact : $elapsed seconds\n"; $startTime = microtime(true); for($i=0; $i<100000; $i++) { $array = [ 'foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz' ]; } $endTime = microtime(true); $elapsed = $endTime - $startTime; echo "Without compact time : $elapsed seconds\n";

preferences:
45.2 ms | 405 KiB | 5 Q