3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ip = '127.0.0.1'; function test($ip) { if (false !== strpos($ip, '/')) { list($address, $netmask) = explode('/', $ip, 2); if ($netmask < 1 || $netmask > 32) { return false; } } else { $address = $ip; $netmask = 32; } $netmask = str_pad(str_pad('', $netmask, '1'), 32, '0'); $in_addr = ''; foreach(array_map('bindec', str_split($netmask, 8)) as $char) { $in_addr .= pack('C*', $char); } $netmask = inet_pton(inet_ntop($in_addr)); $network = inet_pton($address) & $netmask; return [inet_ntop($network), inet_ntop($network | ~$netmask)]; } var_dump(test('127.0.0.1')); var_dump(test('10.0.0.3/29'));

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.70.0000.01516.73
8.3.60.0140.00016.88
8.3.50.0100.00821.93
8.3.40.0120.00319.09
8.3.30.0160.00019.09
8.3.20.0040.00420.16
8.3.10.0070.00023.75
8.3.00.0040.00419.63
8.2.190.0090.00918.42
8.2.180.0090.01218.29
8.2.170.0070.01022.96
8.2.160.0070.00720.39
8.2.150.0050.00324.18
8.2.140.0090.00024.66
8.2.130.0060.00317.63
8.2.120.0000.00826.35
8.2.110.0000.00820.46
8.2.100.0040.00818.16
8.2.90.0040.00419.22
8.2.80.0000.00817.97
8.2.70.0000.00817.63
8.2.60.0030.00518.16
8.2.50.0040.00418.07
8.2.40.0040.00419.50
8.2.30.0030.00520.62
8.2.20.0000.01017.75
8.2.10.0050.00218.27
8.2.00.0040.00418.14
8.1.280.0120.00625.92
8.1.270.0030.00724.04
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0100.00022.23
8.1.230.0060.00617.90
8.1.220.0090.00017.74
8.1.210.0080.00018.77
8.1.200.0060.00317.48
8.1.190.0050.00317.35
8.1.180.0090.00018.10
8.1.170.0040.00418.71
8.1.160.0040.00422.02
8.1.150.0000.00718.97
8.1.140.0060.00319.56
8.1.130.0000.00717.85
8.1.120.0040.00417.50
8.1.110.0040.00417.54
8.1.100.0040.00417.54
8.1.90.0040.00417.52
8.1.80.0040.00417.52
8.1.70.0040.00417.52
8.1.60.0000.00917.66
8.1.50.0040.00417.57
8.1.40.0040.00717.58
8.1.30.0000.00817.74
8.1.20.0030.00617.54
8.1.10.0060.00317.66
8.1.00.0040.00417.55
8.0.300.0040.00418.77
8.0.290.0070.00416.75
8.0.280.0040.00418.53
8.0.270.0050.00517.22
8.0.260.0030.00317.44
8.0.250.0000.00717.04
8.0.240.0070.00017.05
8.0.230.0000.00717.03
8.0.220.0050.00217.02
8.0.210.0030.00316.87
8.0.200.0030.00316.90
8.0.190.0000.00716.90
8.0.180.0090.00317.00
8.0.170.0040.00417.02
8.0.160.0040.00317.02
8.0.150.0040.00416.93
8.0.140.0050.00316.96
8.0.130.0000.00613.50
8.0.120.0000.00716.92
8.0.110.0040.00416.99
8.0.100.0000.00716.96
8.0.90.0040.00416.88
8.0.80.0030.01316.86
8.0.70.0070.00016.89
8.0.60.0050.00216.91
8.0.50.0040.00416.94
8.0.30.0120.00517.22
8.0.20.0150.01817.40
8.0.10.0040.00416.94
8.0.00.0080.01217.02
7.4.330.0000.00516.96
7.4.320.0030.00316.57
7.4.300.0000.00816.59
7.4.290.0000.00716.59
7.4.280.0050.00216.58
7.4.270.0080.00016.51
7.4.260.0000.00716.62
7.4.250.0040.00416.63
7.4.240.0030.00416.69
7.4.230.0040.00416.80
7.4.220.0170.00716.71
7.4.210.0000.01416.66
7.4.200.0040.00416.76
7.4.160.0080.00816.75
7.4.150.0030.01417.40
7.4.140.0140.00517.86
7.4.130.0060.01216.59
7.4.120.0070.01016.61
7.4.110.0180.00416.57
7.4.100.0150.00516.72
7.4.90.0070.01116.63
7.4.80.0110.00619.39
7.4.70.0140.00316.47
7.4.60.0080.00816.53
7.4.50.0110.00016.28
7.4.40.0100.00716.35
7.4.30.0170.00716.76
7.4.00.0030.01414.91
7.3.330.0000.00613.27
7.3.320.0050.00013.45
7.3.310.0070.00016.29
7.3.300.0070.00016.44
7.3.290.0060.01216.43
7.3.280.0080.00916.38
7.3.270.0060.01217.40
7.3.260.0130.01016.68
7.3.250.0100.00716.40
7.3.240.0110.00616.41
7.3.230.0080.00816.54
7.3.210.0090.00916.41
7.3.200.0100.01016.68
7.3.190.0070.01116.69
7.3.180.0080.00816.64
7.3.170.0030.01416.43
7.3.160.0090.00916.75
7.3.120.0060.00614.60
7.3.110.0120.00314.68
7.3.100.0030.00914.59
7.3.90.0070.00715.02
7.3.80.0000.01014.97
7.3.70.0060.01214.86
7.3.60.0020.00514.97
7.3.50.0060.00914.88
7.3.40.0030.00614.80
7.3.30.0000.01114.80
7.3.20.0000.01216.76
7.3.10.0110.00816.31
7.3.00.0120.00416.51
7.2.330.0140.00616.55
7.2.320.0100.01016.71
7.2.310.0030.01616.64
7.2.300.0150.00316.96
7.2.290.0060.01216.75
7.2.240.0050.00514.91
7.2.230.0100.00715.07
7.2.220.0110.00415.04
7.2.210.0080.00415.25
7.2.200.0040.01414.84
7.2.190.0150.00015.03
7.2.180.0030.00615.16
7.2.170.0080.00415.02
7.2.160.0000.01614.98
7.2.150.0030.01017.11
7.2.140.0080.00017.01
7.2.130.0090.00716.71
7.2.120.0160.00616.83
7.2.110.0060.01216.85
7.2.100.0030.01016.84
7.2.90.0070.01016.77
7.2.80.0120.00717.02
7.2.70.0080.00916.88
7.2.60.0120.00216.81
7.2.50.0080.00916.61
7.2.40.0110.00916.85
7.2.30.0140.01017.01
7.2.20.0100.01016.87
7.2.10.0140.00916.69
7.2.00.0070.01017.82
7.1.330.0040.01115.87
7.1.320.0080.00015.76
7.1.310.0030.01015.94
7.1.300.0030.01015.97
7.1.290.0040.01115.78
7.1.280.0060.00615.74
7.1.270.0030.00915.96
7.1.260.0040.00415.55
7.1.250.0080.00815.72
7.1.200.0030.00715.59
7.1.70.0000.01017.28
7.1.60.0050.00517.03
7.1.50.0110.01116.99
7.1.00.0070.07022.39
7.0.200.0060.00916.86
7.0.60.0030.08019.96
7.0.50.0030.04017.93
7.0.40.0030.09020.28
7.0.30.0470.06320.32
7.0.20.0330.08020.22
7.0.10.0070.04720.29
7.0.00.0000.09020.22
5.6.280.0030.04320.93
5.6.210.0130.07320.70
5.6.200.0130.07718.21
5.6.190.0000.09020.40
5.6.180.0270.05320.45
5.6.170.0270.06320.51
5.6.160.0070.08320.51
5.6.150.0100.08018.19
5.6.140.0070.08318.24
5.6.130.0100.08018.34
5.6.120.0100.08321.05
5.6.110.0070.07721.08
5.6.100.0030.04021.07
5.6.90.0130.08021.02
5.6.80.0070.08320.46
5.5.350.4200.04020.54
5.5.340.0030.04318.02
5.5.330.0070.08020.63
5.5.320.0000.06720.41
5.5.310.0200.06020.37
5.5.300.0230.06018.01
5.5.290.0000.08718.01
5.5.280.0030.04320.91
5.5.270.0200.07020.72
5.5.260.0100.03720.80
5.5.250.0170.07320.73
5.5.240.0300.07320.20

preferences:
42.43 ms | 401 KiB | 5 Q