3v4l.org

run code in 300+ PHP versions simultaneously
<?php $area_codes = array( '015019', '015020', '01511', '01512', '01514', '01515', '01516', '01517', '015180', '015181', '015182', '015183', '015184', '015185', ); // Build an associative array $area_lookup = []; foreach($area_codes as $code) $area_lookup[$code] = 1; function splitNumber(array $area_lookup, string $telephone_number): array { for($len=4;$len<=6;$len++) { $prefix = substr($telephone_number, 0, $len); if(isset($area_lookup[$prefix])) return ['area_code' => $prefix, 'subscriber_number' => substr($telephone_number, $len)]; } throw new Exception('Invalid number'); } $res1 = splitNumber($area_lookup, '015169999999'); $res2 = splitNumber($area_lookup, '015180999999'); var_dump($res1, $res2);

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.10.0090.00918.53
8.5.00.0110.01119.95
8.4.150.0030.00014.05
8.4.140.0160.00517.44
8.4.130.0050.00517.89
8.4.120.0190.00820.52
8.4.110.0120.00717.91
8.4.100.0070.00318.54
8.4.90.0110.01118.00
8.4.80.0040.00517.70
8.4.70.0100.01219.71
8.4.60.0050.00419.72
8.4.50.0340.01117.71
8.4.40.0360.01317.27
8.4.30.0280.01017.04
8.4.20.0190.00417.33
8.4.10.0190.01017.24
8.3.280.0140.00618.41
8.3.270.0190.00516.84
8.3.260.0110.00716.79
8.3.250.0100.00718.93
8.3.240.0080.00117.16
8.3.230.0060.00416.42
8.3.220.0150.00718.32
8.3.210.0100.01016.92
8.3.200.0110.00816.50
8.3.190.0070.00816.53
8.3.180.0160.00518.91
8.3.170.0170.00516.29
8.3.160.0170.00416.44
8.3.150.0170.00416.79
8.3.140.0170.00316.67
8.3.130.0160.00516.42
8.3.120.0140.00416.83
8.3.110.0180.00216.35
8.3.100.0190.00116.36
8.3.90.0210.00516.50
8.3.80.0150.00716.49
8.3.70.0190.00216.68
8.3.60.0240.00816.34
8.3.50.0200.00216.53
8.3.40.0130.00517.43
8.3.30.0130.00417.16
8.3.20.0180.00217.34
8.3.10.0280.00417.41
8.3.00.0170.00817.44
8.2.290.0080.01120.42
8.2.280.0170.00618.59
8.2.270.0190.00716.45
8.2.260.0140.00516.70
8.2.250.0140.00316.73
8.2.240.0180.00516.66
8.2.230.0140.00516.36
8.2.220.0140.00416.52
8.2.210.0260.00616.42
8.2.200.0240.00616.41
8.2.190.0270.00216.29
8.2.180.0160.00516.51
8.2.170.0300.00617.60
8.2.160.0230.00417.55
8.2.150.0140.01117.27
8.2.140.0250.00917.79
8.2.130.0220.00917.28
8.2.120.0240.01017.57
8.2.110.0120.00617.65
8.2.100.0190.01217.61
8.2.90.0230.00417.61
8.2.80.0210.00917.38
8.2.70.0250.01017.34
8.2.60.0210.00517.57
8.2.50.0170.00317.57
8.2.40.0170.00117.59
8.2.30.0160.00417.56
8.2.20.0190.00417.51
8.2.10.0250.00117.32
8.2.00.0190.00517.43

preferences:
54.99 ms | 403 KiB | 5 Q