3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertIPv6To4($ip) { // validate if given IP is a proper IPv6 address if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) { // validate if given IP is a proper IPv4 address if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) { // ip address is invalid return ''; } return $ip; } // check if ip is a masked IPv4 address if (substr($ip, 0, 7) == '::ffff:') { $ip = substr($ip, 7); if (preg_match('~^([a-f0-9]{1,4}):([a-f0-9]{1,4})$~', $ip, $matches)) { $ip = array( base_convert($matches[1], 16, 10), base_convert($matches[2], 16, 10) ); $ipParts = array(); $tmp = $ip[0] % 256; $ipParts[] = ($ip[0] - $tmp) / 256; $ipParts[] = $tmp; $tmp = $ip[1] % 256; $ipParts[] = ($ip[1] - $tmp) / 256; $ipParts[] = $tmp; return implode('.', $ipParts); } else { return $ip; } } else { // given ip is an IPv6 address and cannot be converted return $ip; } } echo convertIPv6To4('::ffff:bc65:d048');

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.0180.00418.56
8.3.50.0110.00721.36
8.3.40.0080.00819.15
8.3.30.0070.00719.08
8.3.20.0070.00720.16
8.3.10.0040.00420.73
8.3.00.0110.00019.51
8.2.180.0070.01116.74
8.2.170.0100.01022.96
8.2.160.0110.00420.35
8.2.150.0100.00324.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0000.00822.14
8.2.110.0070.00320.51
8.2.100.0040.00718.09
8.2.90.0030.00618.16
8.2.80.0060.00317.97
8.2.70.0000.00817.75
8.2.60.0040.00418.00
8.2.50.0080.00017.88
8.2.40.0080.00019.52
8.2.30.0040.00419.33
8.2.20.0030.00517.96
8.2.10.0040.00418.07
8.2.00.0000.00818.05
8.1.280.0100.01025.92
8.1.270.0080.00023.91
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0070.01022.64
8.1.230.0070.00322.70
8.1.220.0040.00417.74
8.1.210.0090.00018.91
8.1.200.0050.00317.48
8.1.190.0060.00317.47
8.1.180.0040.00418.10
8.1.170.0040.00417.63
8.1.160.0080.00022.05
8.1.150.0080.00018.93
8.1.140.0060.00317.61
8.1.130.0030.00317.78
8.1.120.0040.00417.54
8.1.110.0080.00017.63
8.1.100.0040.00417.64
8.1.90.0000.00817.65
8.1.80.0080.00017.53
8.1.70.0040.00417.58
8.1.60.0000.00817.69
8.1.50.0030.00617.62
8.1.40.0000.00917.69
8.1.30.0050.00317.71
8.1.20.0030.00617.88
8.1.10.0000.00717.72
8.1.00.0000.00817.53
8.0.300.0050.00320.01
8.0.290.0000.00916.88
8.0.280.0070.00018.48
8.0.270.0000.00717.29
8.0.260.0000.00717.28
8.0.250.0070.00017.17
8.0.240.0040.00417.18
8.0.230.0030.00317.06
8.0.220.0040.00417.18
8.0.210.0040.00417.02
8.0.200.0000.00717.15
8.0.190.0040.00417.16
8.0.180.0050.00217.18
8.0.170.0000.00917.05
8.0.160.0030.00317.18
8.0.150.0070.00017.04
8.0.140.0040.00417.04
8.0.130.0060.00013.47
8.0.120.0040.00416.92
8.0.110.0030.00617.12
8.0.100.0040.00417.11
8.0.90.0050.00217.15
8.0.80.0040.01217.16
8.0.70.0080.00017.13
8.0.60.0040.00416.89
8.0.50.0040.00417.11
8.0.30.0080.01417.36
8.0.20.0150.00517.40
8.0.10.0070.00017.23
8.0.00.0080.01017.11
7.4.330.0030.00315.02
7.4.320.0030.00316.71
7.4.300.0030.00316.73
7.4.290.0070.00016.83
7.4.280.0000.00716.82
7.4.270.0000.00716.75
7.4.260.0000.00716.61
7.4.250.0040.00416.60
7.4.240.0040.00416.84
7.4.230.0000.00716.77
7.4.220.0040.01516.83
7.4.210.0140.00016.82
7.4.200.0070.00016.62
7.4.160.0040.01216.65
7.4.150.0110.00717.40
7.4.140.0070.01017.86
7.4.130.0080.00916.84
7.4.120.0100.01016.72
7.4.110.0120.00616.58
7.4.100.0070.01016.67
7.4.90.0180.00316.50
7.4.80.0070.01019.37
7.4.70.0120.00816.77
7.4.60.0120.00616.78
7.4.50.0000.00816.69
7.4.40.0100.00716.56
7.4.30.0120.00416.80
7.4.00.0060.01115.16
7.3.330.0060.00013.50
7.3.320.0030.00313.39
7.3.310.0070.00016.60
7.3.300.0030.00316.53
7.3.290.0110.00416.46
7.3.280.0090.00816.45
7.3.270.0120.01217.40
7.3.260.0170.00416.70
7.3.250.0060.01116.67
7.3.240.0070.01316.51
7.3.230.0070.01316.57
7.3.210.0030.01316.63
7.3.200.0120.00619.39
7.3.190.0120.00916.63
7.3.180.0060.01016.72
7.3.170.0130.00316.88
7.3.160.0170.00616.51
7.3.120.0110.00714.93
7.3.110.0060.01214.94
7.3.100.0090.00615.00
7.3.90.0070.00315.32
7.3.80.0030.00614.81
7.3.70.0060.00914.69
7.3.60.0000.01215.12
7.3.50.0070.01014.84
7.3.40.0120.00315.11
7.3.30.0110.00014.91
7.3.20.0070.00716.56
7.3.10.0090.00316.95
7.3.00.0090.00316.92
7.2.330.0030.01316.95
7.2.320.0110.00616.93
7.2.310.0090.01016.84
7.2.300.0090.00916.77
7.2.290.0100.00616.91
7.2.250.0100.01015.52
7.2.240.0040.01815.36
7.2.230.0070.01114.93
7.2.220.0000.00815.27
7.2.210.0030.01315.18
7.2.200.0080.00815.48
7.2.190.0090.00315.26
7.2.180.0040.01515.18
7.2.170.0030.01015.26
7.2.60.0040.01217.06
7.2.00.0090.00019.78
7.1.330.0120.00015.82
7.1.320.0080.00016.02
7.1.310.0060.00615.71
7.1.300.0100.00616.01
7.1.290.0030.01016.00
7.1.280.0000.01316.11
7.1.270.0060.01115.89
7.1.260.0040.00415.99
7.1.200.0080.00815.75
7.1.100.0000.01118.14
7.1.70.0060.00617.31
7.1.60.0090.01619.32
7.1.50.0170.01017.16
7.1.00.0070.07322.33
7.0.200.0380.00617.00
7.0.140.0000.07722.08
7.0.70.0030.04021.63
7.0.60.0000.04721.85
7.0.50.0000.03722.39
7.0.40.0030.04720.42
7.0.30.0000.06020.46
7.0.20.0070.07720.50
7.0.10.0000.04320.34
7.0.00.0070.07720.34
5.6.280.0000.07721.00
5.6.220.0000.04020.62
5.6.210.0000.04320.65
5.6.200.0000.03720.97
5.6.190.0030.03721.11
5.6.180.0000.06721.08
5.6.170.0000.04021.18
5.6.160.0030.04321.04
5.6.150.0070.03321.07
5.6.140.0030.03021.02
5.6.130.0070.03021.06
5.6.120.0070.04721.00
5.6.110.0030.04021.17
5.6.100.0030.03320.95
5.6.90.0000.03321.06
5.6.80.0030.03020.50
5.6.70.0030.03020.32
5.6.60.0030.03020.48
5.6.50.0000.03720.33
5.6.40.0000.03320.54
5.6.30.0030.03020.44
5.6.20.0030.03020.41
5.6.10.0000.03320.35
5.6.00.0070.02720.30
5.5.360.0000.04320.41
5.5.350.0030.04020.39
5.5.340.0030.03020.84
5.5.330.0000.03720.80
5.5.320.0030.05320.80
5.5.310.0030.03720.93
5.5.300.0000.04720.83
5.5.290.0030.04020.75
5.5.280.0000.03720.92
5.5.270.0030.03320.88
5.5.260.0000.04720.79
5.5.250.0000.03320.69
5.5.240.0000.03320.22
5.5.230.0070.02720.24
5.5.220.0000.03320.21
5.5.210.0030.03020.30
5.5.200.0030.03020.20
5.5.190.0000.03320.21
5.5.180.0070.04020.13
5.5.160.0000.04020.12
5.5.150.0000.03320.28
5.5.140.0030.03020.28
5.5.130.0070.04320.24
5.5.120.0030.05720.24
5.5.110.0030.03320.25
5.5.100.0070.06720.07
5.5.90.0000.06720.14
5.5.80.0070.06720.07
5.5.70.0030.07720.14
5.5.60.0070.07020.04
5.5.50.0030.07320.11
5.5.40.0030.04720.09
5.5.30.0000.07020.08
5.5.20.0030.08320.07
5.5.10.0000.05020.10
5.5.00.0030.07320.08
5.4.450.0030.04019.25
5.4.440.0000.03319.41
5.4.430.0000.03319.45
5.4.420.0000.03319.43
5.4.410.0000.03719.06
5.4.400.0000.03719.03
5.4.390.0000.03019.18
5.4.380.0000.03018.95
5.4.370.0000.03019.20
5.4.360.0030.03019.04
5.4.350.0000.03319.07
5.4.340.0000.03319.12
5.4.320.0030.03319.20
5.4.310.0030.03019.21
5.4.300.0000.03019.18
5.4.290.0030.03318.93
5.4.280.0000.05319.02
5.4.270.0030.03719.09
5.4.260.0000.04018.88
5.4.250.0070.06019.11
5.4.240.0030.07319.03
5.4.230.0100.06319.08
5.4.220.0030.08019.01
5.4.210.0100.06718.84
5.4.200.0030.07719.09
5.4.190.0070.06019.02
5.4.180.0030.07319.19
5.4.170.0030.06719.00
5.4.160.0030.07018.82
5.4.150.0000.08319.16
5.4.140.0070.07716.36
5.4.130.0100.06316.40
5.4.120.0000.06316.20
5.4.110.0000.06316.26
5.4.100.0030.06716.50
5.4.90.0030.05316.44
5.4.80.0000.06016.34
5.4.70.0070.06716.32
5.4.60.0070.06316.44
5.4.50.0030.07716.45
5.4.40.0030.07316.34
5.4.30.0070.06716.39
5.4.20.0030.07016.36
5.4.10.0000.07316.41
5.4.00.0000.06015.85
5.3.290.0000.03314.74
5.3.280.0030.07014.57
5.3.270.0070.06314.57
5.3.260.0000.07314.64
5.3.250.0070.07314.68
5.3.240.0030.06714.62
5.3.230.0030.07314.63
5.3.220.0070.07314.59
5.3.210.0030.08014.54
5.3.200.0000.07714.64
5.3.190.0030.07014.60
5.3.180.0000.07714.55
5.3.170.0000.06314.63
5.3.160.0030.07714.60
5.3.150.0070.07314.52
5.3.140.0070.07314.62
5.3.130.0030.07314.65
5.3.120.0070.07014.58
5.3.110.0000.07314.62
5.3.100.0000.06313.97
5.3.90.0030.07714.09
5.3.80.0070.04714.03
5.3.70.0030.07014.17
5.3.60.0030.05714.04
5.3.50.0070.06713.85
5.3.40.0070.06313.95
5.3.30.0000.07013.90
5.3.20.0030.06013.71
5.3.10.0000.07313.64
5.3.00.0030.07313.63
5.2.170.0070.05711.22
5.2.160.0030.06711.04
5.2.150.0000.06711.21
5.2.140.0030.05311.29
5.2.130.0070.05311.23
5.2.120.0030.06311.19
5.2.110.0000.06311.22
5.2.100.0030.03711.16
5.2.90.0000.05311.13
5.2.80.0030.05311.13
5.2.70.0000.06311.21
5.2.60.0000.04710.92
5.2.50.0100.04011.12
5.2.40.0070.05310.94
5.2.30.0030.05310.97
5.2.20.0030.06010.84
5.2.10.0030.05310.98
5.2.00.0030.06310.84
5.1.60.0000.05710.50
5.1.50.0030.04710.50
5.1.40.0030.04710.50
5.1.30.0030.03710.50
5.1.20.0030.05010.50
5.1.10.0030.04710.50
5.1.00.0030.02310.50
5.0.50.0000.03310.50
5.0.40.0030.03310.50
5.0.30.0030.06010.50
5.0.20.0000.02310.50
5.0.10.0030.04310.50
5.0.00.0000.03710.50
4.4.90.0000.03010.50
4.4.80.0030.02310.50
4.4.70.0000.03010.50
4.4.60.0000.03710.50
4.4.50.0030.02710.50
4.4.40.0000.05010.50
4.4.30.0000.03010.50
4.4.20.0030.02010.50
4.4.10.0070.03010.50
4.4.00.0000.04010.50
4.3.110.0030.01710.50
4.3.100.0000.03310.50
4.3.90.0000.02710.50
4.3.80.0030.05010.50
4.3.70.0030.03010.50
4.3.60.0030.03310.50
4.3.50.0000.03010.50
4.3.40.0000.04710.50
4.3.30.0000.03010.50
4.3.20.0030.02310.50
4.3.10.0030.03010.50
4.3.00.0030.03310.50

preferences:
44.79 ms | 401 KiB | 5 Q