3v4l.org

run code in 300+ PHP versions simultaneously
<?php function odd ( $var ) { // returns whether the input integer is odd return( $var & 1 ); } function even ( $var ) { // returns whether the input integer is even return(!( $var & 1 )); } $array1 = array( "a" => 1 , "b" => 2 , "c" => 3 , "d" => 4 , "e" => 5 ); $array2 = array( 6 , 7 , 8 , 9 , 10 , 11 , 12 ); echo "Odd :\n" ; print_r ( array_filter ( $array1 , "odd" )); echo "Even:\n" ; print_r ( array_filter ( $array2 , "even" )); $input = array( "Neo" , "Morpheus" , "Trinity" , "Cypher" , "Tank" ); $rand_keys = array_rand ( $input , 2 ); echo $input [ $rand_keys [ 0 ]] . "\n" ; echo $input [ $rand_keys [ 1 ]] . "\n" ; $arr=['a'=>4,6,3];var_dump($arr); function cmp ( $a , $b ) { return strcmp ( $a [ "fruit" ], $b [ "fruit" ]); } $fruits [ 0 ][ "fruit" ] = "lemons" ; $fruits [ 1 ][ "fruit" ] = "apples" ; $fruits [ 2 ][ "fruit" ] = "grapes" ; print_r($fruits); usort ( $fruits , "cmp" ); while (list( $key , $value ) = each ( $fruits )) { echo " $fruits [ $key ] : " . $value [ "fruit" ] . "\n" ; } $a = array( 3 , 2 , 5 , 6 , 1 ); usort ( $a , "cmp" ); foreach ( $a as $key => $value ) { echo " $key : $value \n" ; }

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.4.60.0150.01215.88
7.4.50.0160.01516.51
7.4.40.0170.01416.58
7.4.30.0220.00816.30
7.4.20.0150.01116.48
7.4.10.0210.00816.36
7.4.00.0070.01816.18
7.3.180.0150.01216.05
7.3.170.0200.00916.35
7.3.160.0130.01316.36
7.3.150.0190.00916.23
7.3.140.0170.01316.34
7.3.130.0160.01616.43
7.3.120.0180.00916.37
7.3.110.0170.01116.15
7.3.100.0160.00616.11
7.3.90.0170.01316.13
7.3.80.0200.01116.45
7.3.70.0180.00616.11
7.3.60.0150.01616.25
7.3.50.0130.01316.07
7.3.40.0150.01216.30
7.3.30.0110.01616.36
7.3.20.0130.01218.02
7.3.10.0240.00017.92
7.3.00.0200.00918.06
7.2.310.0120.01216.17
7.2.300.0240.00516.83
7.2.290.0200.00816.52
7.2.280.0180.01116.46
7.2.270.0160.01716.51
7.2.260.0170.00916.42
7.2.250.0080.01916.56
7.2.240.0190.00916.20
7.2.230.0110.01116.04
7.2.220.0090.01816.34
7.2.210.0150.01216.08
7.2.200.0120.01516.48
7.2.190.0220.01016.53
7.2.180.0180.00616.07
7.2.170.0080.01816.34
7.2.160.0240.00316.29
7.2.150.0260.00518.15
7.2.140.0170.01318.18
7.2.130.0240.00418.31
7.2.120.0190.00918.03
7.2.110.0180.00718.16
7.2.100.0110.01517.95
7.2.90.0120.01218.09
7.2.80.0150.01118.07
7.2.70.0130.01118.16
7.2.60.0080.01718.02
7.2.50.0180.00917.85
7.2.40.0170.00917.99
7.2.30.0190.00817.98
7.2.20.0170.00818.02
7.2.10.0140.01817.86
7.2.00.0070.00818.94
7.1.330.0250.00917.49
7.1.320.0320.00517.30
7.1.310.0230.01117.38
7.1.300.0170.01717.34
7.1.290.0270.00617.53
7.1.280.0270.00817.56
7.1.270.0220.00817.48
7.1.260.0300.00317.32
7.1.250.0220.01317.37
7.1.240.0240.01117.25
7.1.230.0270.00317.24
7.1.220.0280.01017.45
7.1.210.0250.01017.43
7.1.200.0310.00317.23
7.1.190.0270.00517.20
7.1.180.0140.01917.43
7.1.170.0290.00317.50
7.1.160.0250.00817.51
7.1.150.0290.00617.42
7.1.140.0210.01317.37
7.1.130.0290.00617.34
7.1.120.0260.00517.53
7.1.110.0160.01617.50
7.1.100.0320.00717.34
7.1.90.0150.01517.45
7.1.80.0210.01117.39
7.1.70.0140.00717.32
7.1.60.0170.01018.45
7.1.50.0160.01117.12
7.1.40.0150.01517.50
7.1.30.0230.00817.41
7.1.20.0210.01417.32
7.1.10.0250.01117.47
7.1.00.0140.04519.94
7.0.330.0250.01016.91
7.0.320.0220.01317.09
7.0.310.0140.02317.31
7.0.300.0270.00717.09
7.0.290.0240.00817.04
7.0.280.0160.01716.91
7.0.270.0270.00417.12
7.0.260.0190.01617.02
7.0.250.0200.01417.11
7.0.240.0210.01117.22
7.0.230.0280.00317.15
7.0.220.0230.00917.15
7.0.210.0230.00716.92
7.0.200.0200.00216.00
7.0.190.0210.00917.13
7.0.180.0260.00317.13
7.0.170.0220.01017.03
7.0.160.0230.01017.03
7.0.150.0170.02117.17
7.0.140.0150.04119.59
7.0.130.0240.01216.98
7.0.120.0120.03919.63
7.0.110.0140.01817.07
7.0.100.0200.01216.96
7.0.90.0190.01516.94
7.0.80.0190.01317.28
7.0.70.0200.01217.00
7.0.60.0230.04118.59
7.0.50.0150.04317.57
7.0.40.0160.04517.37
7.0.30.0140.03017.39
7.0.20.0160.03317.49
7.0.10.0160.03617.34
7.0.00.0130.04817.42
5.6.400.0310.00716.23
5.6.390.0240.01516.29
5.6.380.0300.00916.29
5.6.370.0230.00916.25
5.6.360.0130.02016.37
5.6.350.0170.02115.74
5.6.340.0250.01115.87
5.6.330.0190.01416.36
5.6.320.0250.01315.98
5.6.310.0260.01016.10
5.6.300.0320.00715.98
5.6.290.0250.01316.14
5.6.280.0200.03918.49
5.6.270.0250.00815.99
5.6.260.0240.01616.15
5.6.250.0280.00616.27
5.6.240.0220.01216.20
5.6.230.0180.01816.16
5.6.220.0210.01116.12
5.6.210.0150.03318.29
5.6.200.0100.03017.08
5.6.190.0180.04517.13
5.6.180.0160.03817.18
5.6.170.0170.03817.27
5.6.160.0150.04817.13
5.6.150.0250.03617.23
5.6.140.0170.04516.99
5.6.130.0210.02417.17
5.6.120.0170.04617.29
5.6.110.0170.04317.06
5.6.100.0140.04617.21
5.6.90.0190.03416.90
5.6.80.0150.04716.63
5.6.70.0060.04416.71
5.6.60.0150.03416.77
5.6.50.0130.03716.80
5.6.40.0190.04316.74
5.6.30.0150.04116.82
5.6.20.0140.03416.77
5.6.10.0130.04516.77
5.6.00.0160.04416.72
5.5.380.0260.00815.97
5.5.370.0290.00616.04
5.5.360.0210.01115.91
5.5.350.0300.03918.16
5.5.340.0180.04517.04
5.5.330.0150.05116.97
5.5.320.0180.03816.91
5.5.310.0170.04717.02
5.5.300.0150.04316.97
5.5.290.0220.04317.00
5.5.280.0170.03817.03
5.5.270.0170.04017.16
5.5.260.0190.04317.01
5.5.250.0180.03316.96
5.5.240.0150.03916.67
5.5.230.0200.04416.72
5.5.220.0180.04416.76
5.5.210.0140.03516.64
5.5.200.0170.04316.77
5.5.190.0130.03916.70
5.5.180.0150.04816.56
5.5.170.0210.01015.70
5.5.160.0160.03316.73
5.5.150.0150.02916.75
5.5.140.0160.02516.71
5.5.130.0190.04416.60
5.5.120.0140.02616.63
5.5.110.0180.03316.56
5.5.100.0130.03316.68
5.5.90.0140.04116.47
5.5.80.0150.03516.67
5.5.70.0090.03316.67
5.5.60.0170.04016.67
5.5.50.0230.03716.54
5.5.40.0140.02816.65
5.5.30.0110.02716.74
5.5.20.0140.04416.62
5.5.10.0210.02516.43
5.5.00.0130.04316.63
5.4.450.0100.04816.06
5.4.440.0170.04216.27
5.4.430.0090.03116.23
5.4.420.0100.04716.15
5.4.410.0140.03016.13
5.4.400.0180.04015.91
5.4.390.0180.03915.88
5.4.380.0090.04715.88
5.4.370.0100.03315.98
5.4.360.0160.02616.02
5.4.350.0160.04015.95
5.4.340.0100.04715.89
5.4.330.0220.00812.73
5.4.320.0130.03515.86
5.4.310.0130.04216.17
5.4.300.0100.02615.84
5.4.290.0110.02315.88
5.4.280.0150.02315.83
5.4.270.0080.03316.12
5.4.260.0080.04715.95
5.4.250.0130.03715.97
5.4.240.0160.04115.97
5.4.230.0100.04015.92
5.4.220.0160.03816.01
5.4.210.0120.03915.94
5.4.200.0200.03915.95
5.4.190.0090.02516.03
5.4.180.0160.03915.89
5.4.170.0180.03215.91
5.4.160.0110.04315.85
5.4.150.0120.03915.93
5.4.140.0160.03214.60
5.4.130.0110.04114.60
5.4.120.0130.04514.67
5.4.110.0100.02814.70
5.4.100.0120.02014.63
5.4.90.0120.04014.60
5.4.80.0090.04514.53
5.4.70.0120.03814.61
5.4.60.0120.03514.61
5.4.50.0090.02714.59
5.4.40.0110.02314.60
5.4.30.0170.02314.61
5.4.20.0110.02814.69
5.4.10.0160.03314.67
5.4.00.0100.03314.30
5.3.290.0160.03713.80
5.3.280.0120.02613.61
5.3.270.0110.03513.77
5.3.260.0110.03413.84
5.3.250.0120.02313.70
5.3.240.0130.03713.73
5.3.230.0100.04113.79
5.3.220.0110.04213.70
5.3.210.0100.04313.66
5.3.200.0110.02513.65
5.3.190.0100.02413.75
5.3.180.0120.03413.71
5.3.170.0160.03813.79
5.3.160.0100.03113.74
5.3.150.0090.02413.81
5.3.140.0060.04813.72
5.3.130.0100.04413.72
5.3.120.0100.03813.70
5.3.110.0090.02913.72
5.3.100.0060.04413.42
5.3.90.0080.04013.46
5.3.80.0030.03613.38
5.3.70.0110.02513.48
5.3.60.0100.02713.54
5.3.50.0150.03213.42
5.3.40.0090.02413.26
5.3.30.0110.03513.44
5.3.20.0090.03813.20
5.3.10.0090.03913.17
5.3.00.0110.02413.10
5.2.170.0060.02511.43
5.2.160.0100.01711.49
5.2.150.0120.03311.50
5.2.140.0170.02811.54
5.2.130.0150.03111.38
5.2.120.0100.02511.47
5.2.110.0100.03511.52
5.2.100.0110.02611.51
5.2.90.0110.03311.53
5.2.80.0100.02511.37
5.2.70.0080.02511.47
5.2.60.0060.03511.28
5.2.50.0080.01711.39
5.2.40.0070.01811.39
5.2.30.0070.02911.34
5.2.20.0060.02111.36
5.2.10.0070.01811.12
5.2.00.0080.02811.17
5.1.60.0040.02410.38
5.1.50.0110.02610.37
5.1.40.0020.02710.59
5.1.30.0050.02110.68
5.1.20.0050.03310.58
5.1.10.0100.01810.43
5.1.00.0090.02310.37
5.0.50.0080.0239.35
5.0.40.0100.0169.08
5.0.30.0030.0379.06
5.0.20.0100.0139.02
5.0.10.0070.0129.02
5.0.00.0030.0268.97
4.4.90.0060.0108.68
4.4.80.0070.0138.68
4.4.70.0050.0178.68
4.4.60.0040.0118.68
4.4.50.0030.0208.68
4.4.40.0050.0208.68
4.4.30.0080.0118.68
4.4.20.0030.0138.68
4.4.10.0040.0208.68
4.4.00.0040.0228.68
4.3.110.0040.0198.68
4.3.100.0040.0178.68
4.3.90.0050.0088.68
4.3.80.0060.0158.68
4.3.70.0070.0158.68
4.3.60.0050.0128.68
4.3.50.0080.0108.68
4.3.40.0050.0128.68
4.3.30.0040.0218.68
4.3.20.0050.0088.68
4.3.10.0060.0078.68
4.3.00.0060.0098.68

preferences:
28.32 ms | 401 KiB | 5 Q