3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bin_search( $search, $array, $low=0, $high=null, $search = 0 ) { if( $search == count( $array ) ) return null; if( ! is_array( $array ) || empty( $array ) ) return null; if( empty( $high ) ) $high = count( $array ) - 1; // not found if( $low === $high) return null; $mid = floor( ( $high - $low ) / 2 ); $key = ( $high - $mid ) - 1; // found! if( $array[ $key ] === $search ) return $key; if( $search < $array[ $key ] ) { return bin_search( $search, $array, $low, $key, ++$search ); } else { return bin_search( $search, $array, $key, $high, ++$search ); } } $array = range(1,5); $key = bin_search( 3, $array ); echo "Key=" . $key; echo "Value=" . $array[ $key ];

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.0.10.0130.08320.07
7.0.00.0130.08020.21
5.6.280.0030.06721.11
5.6.210.0030.04020.52
5.6.200.0100.08318.22
5.6.190.0000.07320.67
5.6.180.0400.04720.63
5.6.170.0230.05320.47
5.6.160.0130.04020.48
5.6.150.0100.07718.15
5.6.140.0030.07318.25
5.6.130.0130.04718.21
5.6.120.0100.05321.00
5.6.110.0100.07721.00
5.6.100.0100.08721.02
5.6.90.0100.07721.02
5.6.80.0000.04320.38
5.5.350.4170.04720.50
5.5.340.0100.07717.99
5.5.330.0070.04320.13
5.5.320.0430.03320.27
5.5.310.0200.07320.39
5.5.300.0170.05318.04
5.5.290.0070.09018.08
5.5.280.0170.07320.88
5.5.270.0070.05020.93
5.5.260.0100.07020.80
5.5.250.0130.08020.69
5.5.240.0200.06720.27

preferences:
146.12 ms | 1394 KiB | 7 Q