3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(670006151,670006152,670006251); function getPrefixedData($arr){ if(count($arr) == 0) return []; $longest_prefix = strval($arr[0]); foreach($arr as $val){ $val = strval($val); $len = strlen($longest_prefix); for($i=0;$i<$len;++$i){ if($longest_prefix[$i] != $val[$i]){ $longest_prefix = substr($longest_prefix,0,$i); break; } } } $res = []; $len = strlen($longest_prefix); foreach($arr as $index => $val){ if($index == 0) $res[] = $longest_prefix . substr(strval($val),$len); else $res[] = substr(strval($val),$len); } return $res; } print_r(getPrefixedData([670006151,670006152,670006251])); print_r(getPrefixedData([670006151,670006154,670006158])); print_r(getPrefixedData([670006151,670006154,670006161])); print_r(getPrefixedData([670006151,670006154,7])); print_r(getPrefixedData([8,8,8]));

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.5.00.0140.00720.10
8.4.150.0010.00014.05
8.4.140.0080.01317.77
8.4.130.0130.00717.74
8.4.120.0100.00622.21
8.4.110.0140.00718.92
8.4.100.0130.00817.79
8.4.90.0140.00718.81
8.4.80.0130.00719.40
8.4.70.0040.00417.92
8.4.60.0130.01018.91
8.4.50.0090.01024.10
8.4.40.0130.00617.70
8.4.30.0000.00820.52
8.4.20.0120.00917.62
8.4.10.0030.00619.44
8.3.280.0120.00820.21
8.3.270.0130.00616.69
8.3.260.0100.01016.27
8.3.250.0090.00719.04
8.3.240.0110.00916.55
8.3.230.0150.00416.96
8.3.220.0110.00916.63
8.3.210.0040.00418.26
8.3.200.0080.00016.71
8.3.190.0090.00617.23
8.3.180.0100.00916.46
8.3.170.0180.00017.41
8.3.160.0030.01417.45
8.3.150.0090.00917.39
8.3.140.0060.00320.76
8.3.130.0080.00018.40
8.3.120.0080.00020.72
8.3.110.0090.00020.94
8.3.100.0000.00818.30
8.3.90.0060.00926.77
8.3.80.0090.00019.36
8.3.70.0120.00316.75
8.3.60.0090.00616.63
8.3.50.0220.01124.47
8.3.40.0070.01418.71
8.3.30.0040.01118.58
8.3.20.0050.00324.18
8.3.10.0070.00024.66
8.3.00.0060.00326.16
8.2.290.0120.00820.31
8.2.280.0060.00418.60
8.2.270.0030.01516.47
8.2.260.0050.00316.74
8.2.250.0030.00618.16
8.2.240.0050.00517.14
8.2.230.0060.00322.58
8.2.220.0030.01424.06
8.2.210.0090.00626.77
8.2.200.0090.00018.88
8.2.190.0090.00616.66
8.2.180.0120.00325.92
8.2.170.0030.01418.94
8.2.160.0060.01022.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0000.00726.16
8.2.120.0070.00026.35
8.2.110.0060.00321.04
8.2.100.0080.00418.03
8.2.90.0050.00317.75
8.2.80.0040.00418.84
8.2.70.0080.00817.38
8.2.60.0040.00418.16
8.2.50.0030.00518.07
8.2.40.0000.00818.34
8.2.30.0000.00818.05
8.2.20.0000.00718.14
8.2.10.0060.00319.39
8.2.00.0040.00419.25
8.1.330.0090.01022.08
8.1.320.0140.00615.94
8.1.310.0060.00318.06
8.1.300.0000.00916.27
8.1.290.0030.00630.84
8.1.280.0090.00625.92
8.1.270.0040.00423.99
8.1.260.0000.00928.09
8.1.250.0030.00628.09
8.1.240.0070.00417.35
8.1.230.0080.00319.61
8.1.220.0040.00417.78
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0070.00317.23
8.1.180.0080.00018.10
8.1.170.0090.00018.40
8.1.160.0000.00718.91
8.1.150.0050.00218.95
8.1.140.0030.00518.91
8.1.130.0040.00420.03
8.1.120.0040.00417.38
8.1.110.0000.00717.47
8.1.100.0080.00017.50
8.1.90.0040.00417.46
8.1.80.0000.00717.51
8.1.70.0030.00317.45
8.1.60.0000.00917.58
8.1.50.0000.00717.58
8.1.40.0040.00717.55
8.1.30.0090.00017.49
8.1.20.0070.00017.71
8.1.10.0030.00617.55
8.1.00.0040.00417.38
8.0.300.0000.00820.71
8.0.290.0040.00416.75
8.0.280.0030.00318.45
8.0.270.0070.00018.12
8.0.260.0000.00618.59
8.0.250.0000.00716.87
8.0.240.0000.00716.97
8.0.230.0070.00016.90
8.0.220.0060.00316.55
8.0.210.0030.00516.86
8.0.200.0060.00016.84
8.0.190.0030.00517.00
8.0.180.0040.00416.84
8.0.170.0090.00016.90
8.0.160.0050.00216.96
8.0.150.0040.00416.84
8.0.140.0000.00716.69
8.0.130.0000.00613.32
8.0.120.0040.00416.93
8.0.110.0050.00316.77
8.0.100.0090.00016.95
8.0.90.0000.00717.02
8.0.80.0070.00716.87
8.0.70.0000.00816.89
8.0.60.0040.00416.87
8.0.50.0040.00416.89
8.0.30.0130.00417.35
8.0.20.0090.00917.16
8.0.10.0040.00417.07
8.0.00.0110.00816.83
7.4.330.0050.00015.55
7.4.320.0000.00716.51
7.4.300.0060.00016.54
7.4.290.0000.00716.38
7.4.280.0080.00016.58
7.4.270.0000.00716.57
7.4.260.0000.00513.29
7.4.250.0050.00316.48
7.4.240.0030.00316.68
7.4.230.0030.00316.71
7.4.220.0040.00416.60
7.4.210.0070.00816.57
7.4.200.0030.00316.51
7.4.130.0150.00416.44
7.4.120.0070.01116.47
7.4.110.0160.00916.63
7.4.100.0140.02716.36
7.4.90.0180.00016.50
7.4.80.0110.00716.47
7.4.70.0150.00416.45
7.4.60.0170.00716.46
7.4.50.0090.00916.74
7.4.40.0070.01016.48
7.4.30.0100.00716.55
7.4.20.0120.00916.53
7.4.10.0120.00616.59
7.4.00.0150.00316.41
7.3.330.0070.00016.41
7.3.320.0050.00013.15
7.3.310.0070.00016.40
7.3.300.0030.00316.25
7.3.290.0110.00816.37
7.3.260.0190.00516.34
7.3.250.0090.01216.34
7.3.240.0140.00616.39
7.3.230.0100.01416.49
7.3.220.0060.01216.37
7.3.210.0090.00916.43
7.3.200.0100.00716.63
7.3.190.0130.00716.64
7.3.180.0120.01216.59
7.3.170.0030.01716.52
7.3.160.0140.00316.49
7.3.150.0080.00816.37
7.3.140.0100.01016.65
7.3.130.0240.00916.70
7.3.120.0070.01116.55
7.3.110.0100.01016.65
7.3.100.0070.01116.57
7.3.90.0150.00416.44
7.3.80.0120.01216.34
7.3.70.0030.02016.42
7.3.60.0060.01616.33
7.3.50.0090.00916.39
7.3.40.0110.00716.41
7.3.30.0040.01316.51
7.3.20.0080.00916.36
7.3.10.0070.01116.39
7.3.00.0140.00316.48

preferences:
165.62 ms | 403 KiB | 5 Q