3v4l.org

run code in 300+ PHP versions simultaneously
<?php function startsWith($haystack, $needle) { // search backwards starting from haystack length characters from the end return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false; } $mustcontain = 'url/sub/dir/'; $links = array ( 0 => 'url/sub/dir/1234', 1 => 'url/sub/dir/', 2 => 'url/13214124', 3 => 'url/sub/123123123123', ); $finalArr = array(); foreach($links as $v){ if(startsWith($v, $mustcontain)){ $finalArr[] = $v; } } print_r($finalArr);

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.3.60.0070.01418.28
8.3.50.0070.00718.21
8.3.40.0090.00618.67
8.3.30.0070.00718.67
8.3.20.0040.00420.09
8.3.10.0040.00423.64
8.3.00.0070.00319.38
8.2.180.0140.00718.16
8.2.170.0120.00820.64
8.2.160.0070.00722.96
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0050.00322.29
8.2.120.0070.00026.35
8.2.110.0030.00622.20
8.2.100.0110.00017.91
8.2.90.0050.00318.03
8.2.80.0040.00419.11
8.2.70.0080.00017.50
8.2.60.0000.00817.93
8.2.50.0040.00418.10
8.2.40.0000.00820.42
8.2.30.0040.00419.38
8.2.20.0070.00017.82
8.2.10.0050.00218.05
8.2.00.0040.00418.17
8.1.280.0110.00425.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.00623.93
8.1.230.0090.00320.89
8.1.220.0030.00617.74
8.1.210.0000.00818.77
8.1.200.0030.00617.35
8.1.190.0050.00317.23
8.1.180.0040.00418.10
8.1.170.0040.00418.71
8.1.160.0000.00722.18
8.1.150.0000.00718.95
8.1.140.0020.00519.53
8.1.130.0050.00317.70
8.1.120.0040.00417.38
8.1.110.0040.00417.45
8.1.100.0040.00417.46
8.1.90.0040.00417.45
8.1.80.0050.00317.47
8.1.70.0070.00017.54
8.1.60.0040.00417.47
8.1.50.0040.00417.54
8.1.40.0060.00317.55
8.1.30.0080.00017.64
8.1.20.0000.00817.48
8.1.10.0020.00517.45
8.1.00.0030.00617.34
8.0.300.0040.00420.05
8.0.290.0040.00416.75
8.0.280.0040.00418.50
8.0.270.0030.00317.16
8.0.260.0030.00317.22
8.0.250.0000.00716.97
8.0.240.0000.00816.82
8.0.230.0000.01116.94
8.0.220.0070.00016.78
8.0.210.0000.00816.90
8.0.200.0000.00816.98
8.0.190.0030.00616.84
8.0.180.0070.00016.93
8.0.170.0040.00416.81
8.0.160.0000.00717.00
8.0.150.0000.00816.76
8.0.140.0070.00016.73
8.0.130.0000.00513.27
8.0.120.0000.00816.82
8.0.110.0000.00816.97
8.0.100.0000.00716.84
8.0.90.0040.00416.96
8.0.80.0120.00416.77
8.0.70.0050.00316.95
8.0.60.0030.00616.86
8.0.50.0050.00316.96
8.0.30.0090.01017.07
8.0.20.0120.00717.40
8.0.10.0000.00717.07
8.0.00.0100.00616.78
7.4.330.0030.00315.08
7.4.320.0000.00616.52
7.4.300.0030.00316.63
7.4.290.0000.00716.64
7.4.280.0080.00016.54
7.4.270.0030.00316.48
7.4.260.0050.00216.56
7.4.250.0000.00716.37
7.4.240.0040.00416.57
7.4.230.0030.00516.68
7.4.220.0140.01116.48
7.4.210.0070.01016.53
7.4.200.0000.00716.39
7.4.160.0060.00916.66
7.4.150.0110.01117.40
7.4.140.0170.00517.86
7.4.130.0080.01016.47
7.4.120.0090.01016.48
7.4.110.0120.00616.56
7.4.100.0130.00316.59
7.4.90.0110.00616.57
7.4.80.0120.00619.39
7.4.70.0070.01016.42
7.4.60.0170.00016.47
7.4.50.0040.01116.43
7.4.40.0120.00616.46
7.4.30.0130.00916.76
7.4.00.0120.00415.11
7.3.330.0000.00713.19
7.3.320.0070.00013.20
7.3.310.0050.00216.37
7.3.300.0000.00616.41
7.3.290.0040.00416.24
7.3.280.0060.01316.36
7.3.270.0030.01417.40
7.3.260.0070.01016.56
7.3.250.0100.01116.47
7.3.240.0090.00716.50
7.3.230.0070.00916.46
7.3.210.0140.00316.39
7.3.200.0160.00016.36
7.3.190.0060.01616.45
7.3.180.0090.00916.61
7.3.170.0090.01916.58
7.3.160.0090.01216.48
7.2.330.0090.01116.93
7.2.320.0070.01016.76
7.2.310.0120.00616.75
7.2.300.0140.00816.82
7.2.290.0060.01016.86
7.2.60.0030.01016.76
7.2.00.0040.01119.43
7.1.200.0110.01116.05
7.1.70.0030.00617.07
7.1.60.0040.00719.25
7.1.00.0070.07022.50
7.0.200.0790.00914.71
7.0.80.0270.04719.93
7.0.70.0200.06019.93
7.0.60.0170.06320.00
7.0.50.0200.06320.40
7.0.40.0130.06320.45
7.0.30.0170.06020.38
7.0.20.0100.06720.36
7.0.10.0170.06020.35
7.0.00.0200.08720.42
5.6.280.0030.07321.08
5.6.230.0100.06020.82
5.6.220.0130.05720.81
5.6.210.0130.05720.83
5.6.200.0200.08021.03
5.6.190.0070.06321.10
5.6.180.0130.05721.17
5.6.170.0130.05721.02
5.6.160.0170.05321.19
5.6.150.0130.06721.07
5.6.140.0170.05321.08
5.6.130.0070.06721.08
5.6.120.0070.06721.09
5.6.110.0030.07021.02
5.6.100.0170.05321.01
5.6.90.0100.06021.12
5.6.80.0030.06320.48
5.6.70.0100.06020.52
5.6.60.0070.05720.47
5.6.50.0170.05020.47
5.6.40.0230.05320.47
5.6.30.0170.05020.51
5.6.20.0200.05320.44
5.6.10.0100.06020.41
5.6.00.0170.05020.42
5.5.370.0130.05020.45
5.5.360.0170.06020.45
5.5.350.0130.05720.40
5.5.340.0030.06320.92
5.5.330.0100.08320.95
5.5.320.0030.08320.96
5.5.310.0100.06020.86
5.5.300.0130.05720.78
5.5.290.0100.06020.97
5.5.280.0170.05320.93
5.5.270.0130.07320.95
5.5.260.0100.06320.70
5.5.250.0070.06320.74
5.5.240.0170.05320.27
5.5.230.0100.06020.37
5.5.220.0130.06020.33
5.5.210.0170.05320.21
5.5.200.0130.05320.33
5.5.190.0170.05320.21
5.5.180.0100.05720.27
5.5.160.0200.05020.28
5.5.150.0070.05720.31
5.5.140.0100.05320.29
5.5.130.0100.06020.23
5.5.120.0130.05320.31
5.5.110.0100.05720.30
5.5.100.0100.05720.14
5.5.90.0100.05720.01
5.5.80.0170.04720.01
5.5.70.0130.08020.08
5.5.60.0230.06320.20
5.5.50.0170.07320.18
5.5.40.0130.07720.00
5.5.30.0130.05320.00
5.5.20.0200.05020.12
5.5.10.0100.05720.03
5.5.00.0130.05720.18

preferences:
85.15 ms | 401 KiB | 5 Q