3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sov_find_key($findvalue, $array, $increment) { reset($array); $key = array_search($findvalue, $array); if ($key === false || $key === 0){ return false; } if ($increment === 0){ return $key; } $isNegative = $increment < 0 ? true:false; $increment = abs($increment); while(key($array) !== $key) { next($array); } $x=0; while($x < $increment) { if( $isNegative ){ prev($array); } else { next($array); } $x++; } return key($array); } $findvalue = '3'; $array = array( 'A' => 'CONTRACTS', 'B' => '1', 'C' => '2', 'D' => '3', 'E' => '4', 'F' => '5', 'G' => '6'); echo sov_find_key($findvalue, $array, -1);

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)
8.4.120.0050.00423.98
8.4.110.0090.00922.05
8.4.100.0110.00918.84
8.4.90.0100.00120.53
8.4.80.0100.00917.71
8.4.70.0070.00919.40
8.4.60.0090.01119.46
8.4.50.0060.00317.96
8.4.40.0130.00617.93
8.4.30.0130.00320.24
8.4.20.0170.00317.64
8.4.10.0070.00319.41
8.3.250.0110.00718.77
8.3.240.0130.00617.18
8.3.230.0150.00416.38
8.3.220.0090.00618.83
8.3.210.0120.00616.80
8.3.200.0100.00816.52
8.3.190.0020.00516.45
8.3.180.0130.00716.51
8.3.170.0120.00617.16
8.3.160.0130.00316.72
8.3.150.0090.00918.92
8.3.140.0080.00017.18
8.3.130.0100.01018.50
8.3.120.0000.01018.91
8.3.110.0090.00020.94
8.3.100.0100.00024.06
8.3.90.0040.00426.77
8.3.80.0060.00316.50
8.3.70.0130.00616.63
8.3.60.0090.00616.36
8.3.50.0070.00718.32
8.3.40.0060.01321.83
8.3.30.0100.00718.50
8.3.20.0100.00524.92
8.3.10.0090.00525.16
8.3.00.0060.00925.91
8.2.290.0120.00620.56
8.2.280.0050.00416.60
8.2.270.0180.00016.65
8.2.260.0070.01022.08
8.2.250.0070.00016.73
8.2.240.0050.00319.04
8.2.230.0100.00022.58
8.2.220.0000.00837.54
8.2.210.0000.00826.77
8.2.200.0040.00416.25
8.2.190.0070.01116.58
8.2.180.0040.01125.92
8.2.170.0100.00722.96
8.2.160.0090.00622.96
8.2.150.0090.00425.66
8.2.140.0090.00425.16
8.2.130.0120.00425.91
8.2.120.0130.00023.35
8.2.110.0110.00623.35
8.2.100.0060.00921.79
8.2.90.0070.00621.64
8.2.80.0050.00922.14
8.2.70.0060.00821.64
8.2.60.0030.01121.85
8.2.50.0100.00421.79
8.2.40.0060.00621.91
8.2.30.0060.00821.62
8.2.20.0060.00622.99
8.2.10.0080.00321.68
8.2.00.0040.01122.48
8.1.330.0100.00921.98
8.1.320.0090.00916.11
8.1.310.0070.00718.36
8.1.300.0060.00316.31
8.1.290.0040.00718.88
8.1.280.0090.00625.92
8.1.270.0090.00323.92
8.1.260.0050.00626.01
8.1.250.0050.00526.88
8.1.240.0110.00323.26
8.1.230.0060.01021.69
8.1.220.0090.00521.70
8.1.210.0090.00522.22
8.1.200.0090.00621.50
8.1.190.0060.00821.44
8.1.180.0120.00521.88
8.1.170.0050.00721.64
8.1.160.0070.00523.00
8.1.150.0080.00522.16
8.1.140.0100.00321.52
8.1.130.0040.00722.23
8.1.120.0050.00721.54
8.1.110.0050.00921.52
8.1.100.0090.00320.10
8.1.90.0070.00620.20
8.1.80.0110.00320.10
8.1.70.0090.00520.17
8.1.60.0130.00220.25
8.1.50.0090.00420.23
8.1.40.0080.00520.15
8.1.30.0110.00320.35
8.1.20.0080.00620.30
8.1.10.0060.00518.48
8.1.00.0120.00519.48
8.0.300.0070.00522.22
8.0.290.0050.00521.21
8.0.280.0040.00622.02
8.0.270.0060.00621.25
8.0.260.0050.00522.06
8.0.250.0050.00521.32
8.0.240.0050.00721.31
8.0.230.0070.00519.81
8.0.220.0040.00819.76
8.0.210.0090.00319.82
8.0.200.0080.00419.83
8.0.190.0100.00419.84
8.0.180.0080.00519.83
8.0.170.0090.00419.82
8.0.160.0100.00219.84
8.0.150.0080.00419.75
8.0.140.0110.00718.99
8.0.130.0100.00919.03
8.0.120.0110.00619.04
8.0.110.0120.00519.05
8.0.100.0130.00519.06
8.0.90.0150.00419.06
8.0.80.0110.00619.02
8.0.70.0140.00519.01
8.0.60.0120.00719.07
8.0.50.0160.00219.06
8.0.30.0120.00719.10
8.0.20.0090.00819.06
8.0.10.0080.01019.13
8.0.00.0070.00919.12
7.4.330.0060.00420.61
7.4.320.0190.00521.05
7.4.300.0150.00519.59
7.4.290.0170.00519.56
7.4.280.0160.00519.60
7.4.270.0180.00818.82
7.4.260.0150.00818.84
7.4.250.0190.00718.75
7.4.240.0160.00818.79
7.4.230.0190.00418.81
7.4.220.0200.00318.74
7.4.210.0210.00218.81
7.4.200.0160.00518.76
7.4.190.0160.00518.82
7.4.180.0160.00618.86
7.4.160.0180.00518.81
7.4.150.0150.00718.81
7.4.140.0150.00418.68
7.4.130.0160.00518.81
7.4.120.0140.00618.79
7.4.110.0140.00318.73
7.4.100.0110.00818.78
7.4.90.0120.00418.72
7.4.80.0140.00718.74
7.4.70.0110.00718.79
7.4.60.0130.00818.80
7.4.50.0130.00618.69
7.4.40.0130.00818.66
7.4.30.0140.00518.64
7.4.20.0140.00418.71
7.4.10.0150.00418.75
7.4.00.0160.00518.75
7.3.330.0160.00518.65
7.3.320.0160.00618.61
7.3.310.0200.00218.59
7.3.300.0150.00618.57
7.3.290.0150.00518.64
7.3.280.0160.00318.64
7.3.270.0140.00618.70
7.3.260.0150.00618.55
7.3.250.0190.00418.62
7.3.240.0160.00618.65
7.3.230.0140.00618.68
7.3.220.0190.00418.59
7.3.210.0140.00818.53
7.3.200.0140.00918.58
7.3.190.0150.00818.62
7.3.180.0150.00618.59
7.3.170.0160.00418.65
7.3.160.0150.00618.59
7.3.150.0170.00318.65
7.3.140.0150.00518.67
7.3.130.0110.00818.59

preferences:
86.13 ms | 403 KiB | 5 Q