3v4l.org

run code in 300+ PHP versions simultaneously
<?php function normalise_ip($address) { if (preg_match('/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/', $address, $matches)) { // IPv4 address $num = 0; for ($i = 1; $i <= 4; $i++) { $octet = (int) $matches[$i]; if ($octet > 255) { return false; } $num |= $octet << ((4 - $i) * 8); } return sprintf('0000000000000000ffff%04x', $num); } else if (preg_match('/\[?((?:[0-9a-f]{1,4}:|::)+[0-9a-f]{1,4})]?/i', strtolower($address), $matches)) { // IPv6 address $parts = explode(':', $matches[1]); $numParts = count($parts); if ($part[0] === '') { array_splice($parts, 0, 2, array_fill(0, 8 - ($numParts - 2), '0000')); } else if ($parts[$numParts - 1] === '') { array_splice($parts, $numParts - 2, 2, array_fill(0, 8 - ($numParts - 2), '0000')); } else { foreach ($parts as $i => $part) { if ($part === '') { array_splice($parts, $i, 1, array_fill(0, 8 - ($numParts - 1), '0000')); } } } foreach ($parts as &$part) { $part = sprintf('%04s', $part); } return implode('', $parts); } else { // invalid return false; } } echo normalise_ip('192.168.0.1') . "\n"; echo normalise_ip('[::ffff:C0A8:0001]') . "\n";

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.0140.00418.30
8.3.50.0140.01021.21
8.3.40.0100.01019.04
8.3.30.0040.01120.15
8.3.20.0080.00018.98
8.3.10.0080.00021.09
8.3.00.0050.00319.68
8.2.180.0040.01117.00
8.2.170.0220.00022.96
8.2.160.0140.00020.52
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0060.00319.21
8.2.110.0070.00320.35
8.2.100.0060.00618.03
8.2.90.0050.00319.23
8.2.80.0000.00919.21
8.2.70.0090.00617.75
8.2.60.0000.00818.04
8.2.50.0040.00418.07
8.2.40.0030.00620.20
8.2.30.0000.00721.41
8.2.20.0000.00917.98
8.2.10.0000.00818.01
8.2.00.0100.00017.98
8.1.280.0120.00325.92
8.1.270.0080.00023.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.01022.65
8.1.230.0080.00422.70
8.1.220.0000.00818.77
8.1.210.0040.00419.04
8.1.200.0040.00417.48
8.1.190.0040.00417.66
8.1.180.0030.00518.10
8.1.170.0000.00818.71
8.1.160.0040.00419.00
8.1.150.0040.00418.84
8.1.140.0050.00317.71
8.1.130.0020.00517.85
8.1.120.0040.00417.62
8.1.110.0040.00417.61
8.1.100.0040.00417.70
8.1.90.0040.00417.70
8.1.80.0050.00317.55
8.1.70.0070.00017.66
8.1.60.0060.00317.70
8.1.50.0050.00317.68
8.1.40.0080.00017.68
8.1.30.0040.00417.76
8.1.20.0000.00817.76
8.1.10.0000.00817.70
8.1.00.0030.00717.72
8.0.300.0030.00620.15
8.0.290.0040.00417.18
8.0.280.0000.00718.42
8.0.270.0040.00417.40
8.0.260.0000.00716.98
8.0.250.0040.00417.15
8.0.240.0000.01117.20
8.0.230.0000.00717.09
8.0.220.0000.00717.14
8.0.210.0000.00717.10
8.0.200.0030.00317.23
8.0.190.0060.00317.21
8.0.180.0050.00517.08
8.0.170.0040.00417.14
8.0.160.0030.00617.04
8.0.150.0000.00717.05
8.0.140.0000.00817.12
8.0.130.0040.00413.53
8.0.120.0030.00517.13
8.0.110.0000.00717.02
8.0.100.0080.00017.18
8.0.90.0050.00216.98
8.0.80.0070.01417.21
8.0.70.0000.00817.18
8.0.60.0050.00217.02
8.0.50.0050.00317.10
8.0.30.0150.00517.21
8.0.20.0070.01317.40
8.0.10.0030.00517.15
8.0.00.0120.00816.98
7.4.330.0030.00314.94
7.4.320.0030.00316.86
7.4.300.0000.00916.89
7.4.290.0040.00416.74
7.4.280.0050.00216.64
7.4.270.0030.00316.88
7.4.260.0030.00313.47
7.4.250.0040.00416.73
7.4.240.0000.00716.78
7.4.230.0000.00716.94
7.4.220.0030.01416.74
7.4.210.0060.01016.81
7.4.200.0000.00816.51
7.4.190.0030.00416.85
7.4.160.0060.01016.75
7.4.150.0130.00617.40
7.4.140.0100.01117.86
7.4.130.0080.01316.90
7.4.120.0110.00916.88
7.4.110.0090.00916.62
7.4.100.0030.01416.88
7.4.90.0120.00616.79
7.4.80.0090.00919.39
7.4.70.0070.01016.65
7.4.60.0100.00716.77
7.4.50.0060.00316.76
7.4.40.0080.00522.77
7.4.30.0100.01216.86
7.4.00.0070.01215.18
7.3.330.0030.00313.47
7.3.320.0040.00413.45
7.3.310.0030.00316.46
7.3.300.0030.00516.61
7.3.290.0070.00616.60
7.3.280.0100.00916.63
7.3.270.0140.00417.40
7.3.260.0110.00818.24
7.3.250.0080.00816.76
7.3.240.0030.01316.98
7.3.230.0070.01716.86
7.3.210.0130.00316.63
7.3.200.0140.00619.39
7.3.190.0120.00916.91
7.3.180.0110.00616.57
7.3.170.0090.00616.63
7.3.160.0080.00816.81
7.3.120.0070.00915.11
7.3.110.0100.00615.21
7.3.100.0100.00315.05
7.3.90.0000.01014.74
7.3.80.0100.00615.30
7.3.70.0030.00615.16
7.3.60.0080.00415.14
7.3.50.0030.00714.76
7.3.40.0030.00614.87
7.3.30.0100.00315.08
7.3.20.0100.00616.79
7.3.10.0060.00916.81
7.3.00.0040.00816.61
7.2.330.0120.00616.77
7.2.320.0110.01117.04
7.2.310.0100.01116.80
7.2.300.0130.00316.93
7.2.290.0030.01416.95
7.2.250.0120.00615.27
7.2.240.0110.01115.20
7.2.230.0080.00815.12
7.2.220.0030.01015.40
7.2.210.0030.01515.41
7.2.200.0070.00415.12
7.2.190.0070.00715.42
7.2.180.0070.00315.29
7.2.170.0030.01215.18
7.2.00.0030.00719.50
7.1.330.0070.00716.17
7.1.320.0030.01016.09
7.1.310.0040.01416.07
7.1.300.0080.00815.96
7.1.290.0030.00816.17
7.1.280.0030.01215.79
7.1.270.0040.01416.18
7.1.260.0060.00915.98
7.1.100.0080.00618.27
7.1.70.0000.00817.41
7.1.60.0070.01819.24
7.1.50.0260.01335.07
7.1.00.0030.03322.43
7.0.200.0030.00316.94
7.0.140.0000.07322.09
7.0.60.0070.03719.98
7.0.50.0130.08018.02
7.0.40.0100.06020.29
7.0.30.0200.04320.14
7.0.20.0270.07020.32
7.0.10.0100.08320.36
7.0.00.0100.07720.20
5.6.210.0200.06720.52
5.6.200.0000.04718.27
5.6.190.0030.06720.55
5.6.180.0470.06020.48
5.6.170.0300.07020.53
5.6.160.0070.05720.71
5.6.150.0000.04718.12
5.6.140.0100.05318.18
5.6.130.0070.03718.23
5.6.120.0070.04321.14
5.6.110.0000.04320.87
5.6.100.0170.07320.86
5.6.90.0030.06720.99
5.6.80.0070.08020.52
5.5.350.3630.03720.33
5.5.340.0130.07717.96
5.5.330.0130.07320.56
5.5.320.0000.07720.30
5.5.310.0230.04320.34
5.5.300.0100.04018.07
5.5.290.0070.08718.04
5.5.280.0070.04020.69
5.5.270.0000.05720.80
5.5.260.0070.07720.88
5.5.250.0030.08020.63
5.5.240.0170.06320.13
5.4.450.0400.04019.64
5.4.440.0430.05319.46
5.4.430.0530.06319.46
5.4.420.0570.06019.20
5.4.410.0570.06319.45
5.4.400.0330.04018.88
5.4.390.0430.03318.98
5.4.380.0300.04319.08
5.4.370.0500.03719.00
5.4.360.0330.05318.99
5.4.350.0430.04319.22
5.4.340.0470.04719.22
5.4.320.0470.04319.13
5.4.310.0370.04718.95
5.4.300.0500.05018.98
5.4.290.0630.05719.08
5.4.280.0400.04719.13
5.4.270.0430.04719.20
5.4.260.0570.05718.85
5.4.250.0400.04018.86
5.4.240.0470.06718.86
5.4.230.0570.05719.07
5.4.220.0500.07018.86
5.4.210.0530.06319.15
5.4.200.0600.04318.87
5.4.190.0470.07019.13
5.4.180.0600.06019.15
5.4.170.0600.06319.12
5.4.160.0500.07019.17
5.4.150.0530.06019.17
5.4.140.0430.05316.43
5.4.130.0500.06016.40
5.4.120.0500.05316.40
5.4.110.0670.04316.52
5.4.100.0470.07016.61
5.4.90.0530.05716.45
5.4.80.0530.06316.64
5.4.70.0530.06016.60
5.4.60.0470.04016.54
5.4.50.0400.03716.34
5.4.40.0530.06716.53
5.4.30.0500.06716.16
5.4.20.0470.07016.25
5.4.10.0570.06016.44
5.4.00.0600.03715.91
5.3.290.0570.06314.80
5.3.280.0470.04714.70
5.3.270.0470.05314.53
5.3.260.0670.05714.67
5.3.250.0600.06314.66
5.3.240.0530.06314.62
5.3.230.0500.07014.69
5.3.220.0530.06014.49
5.3.210.0400.04014.50
5.3.200.0500.04314.70
5.3.190.0600.05314.50
5.3.180.0400.04014.55
5.3.170.0430.05314.59
5.3.160.0530.05014.48
5.3.150.0400.03714.66
5.3.140.0370.04014.57
5.3.130.0470.04714.61
5.3.120.0500.06714.49
5.3.110.0430.05014.72
5.3.100.0500.05713.98
5.3.90.0670.05013.95
5.3.80.0600.05714.11
5.3.70.0530.05314.20
5.3.60.0470.06014.18
5.3.50.0470.06714.02
5.3.40.0570.06013.98
5.3.30.0530.06314.16
5.3.20.0430.04013.83
5.3.10.0470.05313.83
5.3.00.0470.04313.57
5.2.170.0470.05711.23
5.2.160.0470.05311.09
5.2.150.0400.06011.14
5.2.140.0430.05311.28
5.2.130.0430.05311.24
5.2.120.0470.05311.10
5.2.110.0430.04011.28
5.2.100.0400.03311.10
5.2.90.0230.03311.13
5.2.80.0330.03711.03
5.2.70.0330.06011.12
5.2.60.0400.02311.05
5.2.50.0270.04010.94
5.2.40.0300.05311.07
5.2.30.0330.03010.91
5.2.20.0370.05010.99
5.2.10.0330.05310.83
5.2.00.0300.05310.79
5.1.60.0370.0409.93
5.1.50.0270.04310.13
5.1.40.0330.05010.05
5.1.30.0330.05710.25
5.1.20.0370.04710.49
5.1.10.0400.04710.21
5.1.00.0300.0439.96
5.0.50.0170.0439.93
5.0.40.0230.0409.93
5.0.30.0270.0539.93
5.0.20.0130.0209.93
5.0.10.0170.0439.93
5.0.00.0170.0639.93
4.4.90.0130.0379.93
4.4.80.0100.0179.93
4.4.70.0200.0379.93
4.4.60.0230.0279.93
4.4.50.0270.0209.93
4.4.40.0130.0279.93
4.4.30.0170.0279.93
4.4.20.0170.0309.93
4.4.10.0200.0209.93
4.4.00.0170.0379.93
4.3.110.0130.0279.93
4.3.100.0130.0239.93
4.3.90.0230.0239.93
4.3.80.0170.0539.93
4.3.70.0170.0209.93
4.3.60.0170.0139.93
4.3.50.0130.0179.93
4.3.40.0230.0479.93
4.3.30.0070.0239.93
4.3.20.0100.0379.93
4.3.10.0100.0339.93
4.3.00.0070.0209.93

preferences:
53.28 ms | 401 KiB | 5 Q