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('00000000000000000000ffff%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 ($parts[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.0120.00316.75
8.3.50.0110.00916.83
8.3.40.0150.00019.08
8.3.30.0070.00719.15
8.3.20.0030.00518.98
8.3.10.0030.00618.99
8.3.00.0030.00619.51
8.2.180.0160.00318.34
8.2.170.0120.00322.96
8.2.160.0150.00420.55
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0040.00420.89
8.2.110.0080.00421.06
8.2.100.0040.00818.02
8.2.90.0000.00917.99
8.2.80.0030.00618.05
8.2.70.0060.00318.05
8.2.60.0000.00818.22
8.2.50.0040.00418.10
8.2.40.0040.00419.36
8.2.30.0050.00219.35
8.2.20.0030.00617.82
8.2.10.0080.00017.82
8.2.00.0040.00417.87
8.1.280.0040.01125.92
8.1.270.0030.00524.66
8.1.260.0030.00726.35
8.1.250.0040.00428.09
8.1.240.0110.00317.89
8.1.230.0080.00420.89
8.1.220.0000.00817.89
8.1.210.0000.00818.85
8.1.200.0030.00617.60
8.1.190.0000.00817.60
8.1.180.0000.00818.10
8.1.170.0050.00518.84
8.1.160.0030.00518.86
8.1.150.0080.00019.00
8.1.140.0040.00417.52
8.1.130.0000.00717.86
8.1.120.0000.00717.57
8.1.110.0000.00817.57
8.1.100.0070.00017.66
8.1.90.0040.00417.63
8.1.80.0000.00817.55
8.1.70.0000.00717.61
8.1.60.0050.00317.74
8.1.50.0040.00417.66
8.1.40.0000.00817.72
8.1.30.0040.00417.74
8.1.20.0040.00417.82
8.1.10.0050.00317.82
8.1.00.0050.00217.77
8.0.300.0040.00419.85
8.0.290.0030.00517.00
8.0.280.0070.00018.52
8.0.270.0000.00817.43
8.0.260.0000.00717.01
8.0.250.0040.00417.14
8.0.240.0030.00317.12
8.0.230.0040.00417.04
8.0.220.0030.00317.11
8.0.210.0000.00917.09
8.0.200.0040.00416.97
8.0.190.0080.00017.13
8.0.180.0030.00717.05
8.0.170.0040.00417.09
8.0.160.0000.00717.13
8.0.150.0060.00317.01
8.0.140.0100.00016.94
8.0.130.0030.00313.46
8.0.120.0000.00817.07
8.0.110.0040.00416.98
8.0.100.0000.00716.87
8.0.90.0040.00417.00
8.0.80.0100.00717.05
8.0.70.0060.00317.20
8.0.60.0050.00216.98
8.0.50.0030.00517.00
8.0.30.0060.01217.29
8.0.20.0110.00817.43
8.0.10.0070.00017.18
8.0.00.0060.01317.09
7.4.330.0050.00013.24
7.4.320.0030.00316.88
7.4.300.0000.00616.77
7.4.290.0060.00316.70
7.4.280.0000.00816.77
7.4.270.0040.00416.75
7.4.260.0060.00013.54
7.4.250.0060.00316.82
7.4.240.0030.00316.74
7.4.230.0000.00716.77
7.4.220.0180.01316.89
7.4.210.0060.01016.91
7.4.200.0040.00416.60
7.4.190.0030.00316.91
7.4.160.0100.01016.94
7.4.150.0140.00316.86
7.4.140.0090.00916.77
7.4.130.0110.00616.85
7.4.120.0130.00416.63
7.4.110.0090.00916.79
7.4.100.0030.01716.67
7.4.90.0130.01016.87
7.4.80.0100.00719.39
7.4.70.0080.01416.79
7.4.60.0150.00316.78
7.4.50.0080.00516.50
7.4.40.0030.01216.76
7.4.30.0080.01216.79
7.4.00.0150.00315.16
7.3.330.0000.00713.40
7.3.320.0000.00713.54
7.3.310.0080.00016.61
7.3.300.0030.00316.57
7.3.290.0100.00716.45
7.3.280.0090.00716.50
7.3.270.0150.00916.51
7.3.260.0140.00316.73
7.3.250.0120.00916.63
7.3.240.0070.01116.61
7.3.230.0090.00916.52
7.3.210.0030.01416.62
7.3.200.0150.00916.63
7.3.190.0130.00916.73
7.3.180.0100.00616.79
7.3.170.0100.01016.62
7.3.160.0110.00816.58
7.3.120.0030.01414.91
7.3.110.0070.01114.90
7.3.100.0060.00614.90
7.3.90.0070.00714.64
7.3.80.0100.00615.04
7.3.70.0070.01014.69
7.3.60.0130.00315.05
7.3.50.0070.00415.17
7.3.40.0030.01414.89
7.3.30.0110.00414.79
7.3.20.0060.00916.49
7.3.10.0060.00916.84
7.3.00.0070.00616.70
7.2.330.0150.00916.80
7.2.320.0110.00716.88
7.2.310.0160.00916.83
7.2.300.0070.01016.94
7.2.290.0100.00617.02
7.2.240.0090.00615.43
7.2.230.0070.00715.43
7.2.220.0030.00715.34
7.2.210.0000.01715.33
7.2.200.0060.01115.15
7.2.190.0130.00315.33
7.2.180.0000.01515.31
7.2.170.0120.00615.26
7.2.160.0040.01115.39
7.2.150.0000.01417.04
7.2.140.0060.00617.08
7.2.130.0070.00817.18
7.2.120.0020.01017.00
7.2.110.0060.00917.03
7.2.100.0080.00717.04
7.2.90.0090.00717.04
7.2.80.0100.00817.08
7.2.70.0090.00616.98
7.2.60.0060.00717.17
7.2.50.0020.01117.15
7.2.40.0060.00916.96
7.2.30.0070.00817.14
7.2.20.0080.00417.09
7.2.10.0050.01117.09
7.2.00.0070.00817.73
7.1.330.0000.00915.88
7.1.320.0030.01415.92
7.1.310.0100.00716.01
7.1.300.0100.00715.81
7.1.290.0030.00715.70
7.1.280.0060.00615.92
7.1.270.0110.00415.95
7.1.260.0120.00315.98
7.1.250.0080.00415.89
7.1.240.0040.01116.01
7.1.230.0040.00815.82
7.1.220.0090.00615.62
7.1.210.0070.00715.92
7.1.200.0090.00215.87
7.1.190.0070.00715.82
7.1.180.0110.00315.87
7.1.170.0100.00715.73
7.1.160.0080.00316.07
7.1.150.0110.00415.89
7.1.140.0000.01516.15
7.1.130.0060.00316.12
7.1.120.0030.01016.08
7.1.110.0160.00015.80
7.1.100.0070.00417.00
7.1.90.0090.00415.96
7.1.80.0030.01016.11
7.1.70.0040.00916.55
7.1.60.0080.01017.70
7.1.50.0060.00616.57
7.1.40.0070.01715.68
7.1.30.0030.01016.04
7.1.20.0120.00915.92
7.1.10.0060.00615.97
7.1.00.0030.03919.10
7.0.330.0070.00715.48
7.0.320.0100.00715.27
7.0.310.0030.00615.68
7.0.300.0060.00615.37
7.0.290.0070.01015.34
7.0.280.0190.00615.38
7.0.270.0070.00715.54
7.0.260.0120.00815.48
7.0.250.0080.00815.59
7.0.240.0220.00615.65
7.0.230.0090.00615.48
7.0.220.0000.01015.53
7.0.210.0050.00515.50
7.0.200.0080.00615.41
7.0.190.0080.00015.45
7.0.180.0060.00915.63
7.0.170.0070.00715.39
7.0.160.0060.01015.64
7.0.150.0030.00715.49
7.0.140.0090.03818.68
7.0.130.0160.01015.45
7.0.120.0070.03518.82
7.0.110.0020.02617.71
7.0.100.0080.02017.79
7.0.90.0080.02317.69
7.0.80.0060.01817.69
7.0.70.0070.02017.81
7.0.60.0000.02417.67
7.0.50.0060.02017.79
7.0.40.0030.02616.82
7.0.30.0070.01816.78
7.0.20.0030.02316.67
7.0.10.0040.02216.75
7.0.00.0110.02016.59
5.6.380.0100.00314.25
5.6.370.0070.00714.57
5.6.360.0070.01014.30
5.6.350.0070.00714.27
5.6.340.0130.00314.45
5.6.330.0050.00514.37
5.6.320.0090.00614.66
5.6.310.0080.00814.22
5.6.300.0030.01014.60
5.6.290.0060.00914.53
5.6.280.0060.03717.71
5.6.270.0060.00914.31
5.6.260.0060.01817.53
5.6.250.0030.02117.37
5.6.240.0070.02017.48
5.6.230.0030.02517.71
5.6.220.0070.01817.68
5.6.210.0040.02217.71
5.6.200.0090.01917.63
5.6.190.0100.02317.51
5.6.180.0060.02617.56
5.6.170.0080.02317.35
5.6.160.0020.02417.61
5.6.150.0080.02217.35
5.6.140.0120.02017.57
5.6.130.0100.02517.46
5.6.120.0030.03217.29
5.6.110.0120.04017.56
5.6.100.0170.04217.43
5.6.90.0130.02317.40
5.6.80.0160.02217.14
5.6.70.0100.02117.02
5.6.60.0070.02917.18
5.6.50.0150.02517.21
5.6.40.0090.02917.25
5.6.30.0080.02417.04
5.6.20.0060.03217.33
5.6.10.0110.02117.22
5.6.00.0070.02117.11
5.5.380.0000.02214.36
5.5.370.0050.02014.48
5.5.360.0050.02114.39
5.5.350.0110.02314.37
5.5.340.0030.02014.73
5.5.330.0130.01314.42
5.5.320.0060.02114.60
5.5.310.0050.01814.61
5.5.300.0080.02014.68
5.5.290.0070.03914.61
5.5.280.0100.04414.41
5.5.270.0150.02614.71
5.5.260.0100.04214.56
5.5.250.0060.02314.41
5.5.240.0080.03614.44
5.5.230.0060.02514.14
5.5.220.0120.02014.37
5.5.210.0050.02314.26
5.5.200.0110.02114.21
5.5.190.0070.01814.12
5.5.180.0080.01714.33
5.5.170.0050.00511.06
5.5.160.0100.01714.30
5.5.150.0020.02214.30
5.5.140.0040.02014.40
5.5.130.0090.01814.29
5.5.120.0020.03213.97
5.5.110.0040.02114.28
5.5.100.0050.02514.24
5.5.90.0110.02314.40
5.5.80.0120.01814.29
5.5.70.0070.02014.17
5.5.60.0110.02614.01
5.5.50.0050.02414.38
5.5.40.0020.02614.38
5.5.30.0050.02914.25
5.5.20.0050.02214.20
5.5.10.0010.02414.34
5.5.00.0080.02014.23
5.4.450.0080.01815.12
5.4.440.0070.04115.21
5.4.430.0120.03815.33
5.4.420.0090.02715.28
5.4.410.0080.02615.14
5.4.400.0040.02315.08
5.4.390.0070.03515.22
5.4.380.0160.03915.13
5.4.370.0220.02015.12
5.4.360.0170.03615.01
5.4.350.0070.02215.27
5.4.340.0060.02314.91
5.4.330.0030.00611.25
5.4.320.0050.02315.12
5.4.310.0060.02415.07
5.4.300.0050.01815.03
5.4.290.0080.02015.09
5.4.280.0070.01614.87
5.4.270.0050.02015.04
5.4.260.0060.02215.21
5.4.250.0070.01815.11
5.4.240.0150.01315.06
5.4.230.0080.02815.07
5.4.220.0020.02415.13
5.4.210.0060.03915.21
5.4.200.0040.02415.08
5.4.190.0040.01915.13
5.4.180.0070.01915.19
5.4.170.0000.02314.98
5.4.160.0020.02414.95
5.4.150.0070.01715.09
5.4.140.0040.02013.86
5.4.130.0070.01613.84
5.4.120.0030.02013.84
5.4.110.0010.01913.90
5.4.100.0040.02113.95
5.4.90.0080.01713.81
5.4.80.0090.01813.60
5.4.70.0060.01813.83
5.4.60.0070.01713.75
5.4.50.0010.02113.62
5.4.40.0080.01513.76
5.4.30.0050.01813.81
5.4.20.0050.03913.79
5.4.10.0040.03413.85
5.4.00.0020.02513.56
5.3.290.0050.01512.76
5.3.280.0040.03112.54
5.3.270.0050.02112.67
5.3.260.0050.01812.69
5.3.250.0070.01512.70
5.3.240.0060.02012.65
5.3.230.0000.02512.65
5.3.220.0050.02212.61
5.3.210.0050.01912.58
5.3.200.0050.01812.64
5.3.190.0080.01812.64
5.3.180.0140.01712.74
5.3.170.0100.02312.64
5.3.160.0060.01912.60
5.3.150.0050.01812.62
5.3.140.0060.02012.56
5.3.130.0050.02812.51
5.3.120.0130.03412.63
5.3.110.0110.01812.62
5.3.100.0150.02012.36
5.3.90.0090.01812.46
5.3.80.0060.01712.19
5.3.70.0090.01712.37
5.3.60.0150.01312.36
5.3.50.0160.02312.29
5.3.40.0070.01912.30
5.3.30.0120.03512.29
5.3.20.0090.02712.16
5.3.10.0120.02212.02
5.3.00.0080.03212.08
5.2.170.0050.01510.75
5.2.160.0060.01810.78
5.2.150.0020.01910.75
5.2.140.0090.01510.80
5.2.130.0000.02710.59
5.2.120.0040.01810.73
5.2.110.0020.02410.70
5.2.100.0030.02510.59
5.2.90.0050.02510.71
5.2.80.0050.01710.67
5.2.70.0060.01710.68
5.2.60.0040.01810.67
5.2.50.0050.01610.64
5.2.40.0070.01510.68
5.2.30.0070.01510.69
5.2.20.0060.01510.69
5.2.10.0040.02210.51
5.2.00.0040.01610.57
5.1.60.0070.01810.22
5.1.50.0040.01310.22
5.1.40.0030.01610.27
5.1.30.0060.01710.29
5.1.20.0020.02110.36
5.1.10.0010.01910.20
5.1.00.0090.02310.24
5.0.50.0080.00810.12
5.0.40.0070.01010.12
5.0.30.0000.02510.12
5.0.20.0040.01810.12
5.0.10.0020.02010.12
5.0.00.0020.01910.12
4.4.90.0030.00810.12
4.4.80.0000.01210.12
4.4.70.0020.01310.12
4.4.60.0020.01010.12
4.4.50.0000.01110.12
4.4.40.0040.01210.12
4.4.30.0030.01510.12
4.4.20.0040.00810.12
4.4.10.0060.00710.12
4.4.00.0030.01510.12
4.3.110.0020.01210.12
4.3.100.0000.01210.12
4.3.90.0020.00710.12
4.3.80.0010.02110.12
4.3.70.0030.01710.12
4.3.60.0020.01610.12
4.3.50.0040.01810.12
4.3.40.0040.02010.12
4.3.30.0010.02010.12
4.3.20.0020.01510.12
4.3.10.0070.00810.12
4.3.00.0020.00810.12

preferences:
45.44 ms | 401 KiB | 5 Q