3v4l.org

run code in 300+ PHP versions simultaneously
<?php function outside() { $c = 100; $o = ''; $a = [ '1' => 'one', '2' => 'two' ]; while ( --$c ) { $o .= strtr( $c, $a ); } return $o; } function inside() { $c = 100; $o = ''; while ( --$c ) { $a = [ '1' => 'one', '2' => 'two' ]; $o .= strtr( $c, $a ); } return $o; } $it = 100; $ns = -hrtime( true ); $c = $it; $l = 0; while ( --$c ) { $l += strlen( outside() ); } $ns += hrtime( true ); echo "outside: " . ( $ns / $it / 1e3 ) . " µs/it\n"; $it = 100; $ns = -hrtime( true ); $c = $it; $l = 0; while ( --$c ) { $l += strlen( inside() ); } $ns += hrtime( true ); echo "inside: " . ( $ns / $it / 1e3 ) . " µs/it\n";

preferences:
30.8 ms | 478 KiB | 5 Q