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('2003:66:4f14:d880:7075:9457:3857:29ec') ?>

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.0070.01018.18
8.3.50.0140.00321.13
8.3.40.0070.01418.68
8.3.30.0070.00718.79
8.3.20.0070.01020.34
8.3.10.0040.01120.36
8.3.00.0080.00019.13
8.2.180.0070.01016.63
8.2.170.0120.00922.96
8.2.160.0100.00320.32
8.2.150.0090.00924.18
8.2.140.0070.00724.66
8.2.130.0050.00326.16
8.2.120.0060.00322.11
8.2.110.0030.00622.31
8.2.100.0070.00417.91
8.2.90.0040.00419.11
8.2.80.0000.00817.97
8.2.70.0040.00417.38
8.2.60.0090.00017.80
8.2.50.0060.00318.07
8.2.40.0020.00518.22
8.2.30.0000.00819.13
8.2.20.0000.00717.70
8.2.10.0040.00419.71
8.2.00.0000.00817.59
8.1.280.0060.00925.92
8.1.270.0100.00723.84
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0060.00323.91
8.1.230.0080.00319.10
8.1.220.0060.00317.74
8.1.210.0030.00518.77
8.1.200.0090.00017.09
8.1.190.0000.00816.88
8.1.180.0060.00318.10
8.1.170.0000.00818.64
8.1.160.0000.00721.90
8.1.150.0040.00418.83
8.1.140.0040.00417.40
8.1.130.0030.00317.80
8.1.120.0040.00417.42
8.1.110.0000.00717.42
8.1.100.0000.00717.48
8.1.90.0000.00717.31
8.1.80.0030.00317.29
8.1.70.0030.00317.29
8.1.60.0030.00617.46
8.1.50.0040.00417.38
8.1.40.0000.00717.46
8.1.30.0040.00417.52
8.1.20.0000.00817.66
8.1.10.0020.00517.37
8.1.00.0060.00317.39
8.0.300.0030.00318.77
8.0.290.0020.00516.75
8.0.280.0070.00018.39
8.0.270.0020.00517.12
8.0.260.0030.00317.09
8.0.250.0060.00016.95
8.0.240.0040.00416.84
8.0.230.0030.00316.82
8.0.220.0030.00316.69
8.0.210.0000.00716.78
8.0.200.0000.00716.83
8.0.190.0000.00716.77
8.0.180.0040.00416.71
8.0.170.0040.00416.73
8.0.160.0080.00016.65
8.0.150.0040.00416.76
8.0.140.0040.00416.74
8.0.130.0050.00013.17
8.0.120.0000.01116.63
8.0.110.0030.00516.77
8.0.100.0050.00316.88
8.0.90.0070.00016.80
8.0.80.0070.01416.81
8.0.70.0050.00216.69
8.0.60.0070.00016.80
8.0.50.0040.00416.77
8.0.30.0110.01017.12
8.0.20.0110.01117.40
8.0.10.0040.00416.99
8.0.00.0090.00816.72
7.4.330.0020.00215.03
7.4.320.0040.00316.48
7.4.300.0060.00016.30
7.4.290.0020.00516.43
7.4.280.0070.00016.52
7.4.270.0000.00816.54
7.4.260.0040.00416.55
7.4.250.0050.00216.41
7.4.240.0070.00016.55
7.4.230.0030.00316.48
7.4.220.0040.01416.39
7.4.210.0160.00316.63
7.4.200.0070.00016.62
7.4.160.0100.00716.54
7.4.150.0090.00917.40
7.4.140.0090.00817.86
7.4.130.0090.01016.41
7.4.120.0100.00816.51
7.4.110.0100.00716.52
7.4.100.0070.01016.43
7.4.90.0120.00816.43
7.4.80.0070.01019.37
7.4.70.0150.00616.36
7.4.60.0080.00616.23
7.4.50.0080.00016.61
7.4.40.0100.01316.65
7.4.30.0060.01016.59
7.4.00.0000.01515.13
7.3.330.0070.00013.18
7.3.320.0020.00213.12
7.3.310.0000.00716.27
7.3.300.0070.00016.25
7.3.290.0090.00516.32
7.3.280.0070.00816.19
7.3.270.0110.01617.40
7.3.260.0050.01216.46
7.3.250.0110.00616.51
7.3.240.0110.00616.36
7.3.230.0090.01016.54
7.3.210.0130.00316.21
7.3.200.0110.00619.39
7.3.190.0130.01316.38
7.3.180.0160.00016.48
7.3.170.0060.01016.32
7.3.160.0040.01416.56
7.2.330.0070.01016.71
7.2.320.0060.00916.52
7.2.310.0170.00016.62
7.2.300.0140.00416.75
7.2.290.0180.00016.74
7.2.00.0080.00419.30
7.1.100.0040.00818.19
7.1.70.0000.00716.80
7.1.60.0130.01019.32
7.1.50.0030.02017.05
7.1.00.0000.08022.26
7.0.200.0030.00816.78
7.0.140.0070.07022.08
7.0.60.0100.05719.97
7.0.50.0130.07717.97
7.0.40.0070.07320.05
7.0.30.0470.07020.21
7.0.20.0330.07720.18
7.0.10.0070.06720.35
7.0.00.0100.05720.16
5.6.280.0030.07320.79
5.6.210.0000.07020.49
5.6.200.0100.03718.29
5.6.190.0030.06020.52
5.6.180.0530.07020.47
5.6.170.0270.06320.51
5.6.160.0100.09020.54
5.6.150.0000.08718.18
5.6.140.0070.07718.23
5.6.130.0100.03318.21
5.6.120.0030.04320.94
5.6.110.0070.07321.00
5.6.100.0070.04021.13
5.6.90.0100.04721.01
5.6.80.0070.07720.52
5.5.350.0170.07720.45
5.5.340.0070.07717.98
5.5.330.0100.06020.29
5.5.320.0500.06720.36
5.5.310.0370.05720.34
5.5.300.0030.05318.09
5.5.290.0070.05018.09
5.5.280.0000.05720.79
5.5.270.0100.08020.79
5.5.260.0070.08320.98
5.5.250.0000.05720.72
5.5.240.1570.03720.08
5.4.450.0870.04019.57
5.4.440.0730.06319.58
5.4.430.0830.04719.44
5.4.420.0630.00019.55
5.4.410.0670.00019.26
5.4.400.0630.00019.31
5.4.390.0800.00019.09
5.4.380.0170.06318.77
5.4.370.0400.06318.77
5.4.360.0430.04018.54
5.4.350.0230.06018.77
5.4.340.0370.05718.80
5.4.320.0050.03712.51
5.4.310.0040.03912.51
5.4.300.0060.03612.51
5.4.290.0040.03912.51
5.4.280.0060.03612.41
5.4.270.0110.05212.41
5.4.260.0100.05012.41
5.4.250.0060.04312.41
5.4.240.0070.03612.41
5.4.230.0040.04012.39
5.4.220.0050.03712.40
5.4.210.0070.03512.40
5.4.200.0060.03912.40
5.4.190.0070.03612.39
5.4.180.0040.04412.40
5.4.170.0020.04012.41
5.4.160.0060.03512.39
5.4.150.0060.03512.39
5.4.140.0080.03412.08
5.4.130.0080.03412.06
5.4.120.0060.03512.02
5.4.110.0110.03112.02
5.4.100.0060.03412.02
5.4.90.0030.04012.02
5.4.80.0030.03812.02
5.4.70.0090.03912.02
5.4.60.0080.03812.02
5.4.50.0110.04612.02
5.4.40.0070.03812.01
5.4.30.0020.04012.00
5.4.20.0050.03812.00
5.4.10.0070.03412.00
5.4.00.0050.03711.49
5.3.290.0060.04012.80
5.3.280.0080.04312.71
5.3.270.0080.04312.73
5.3.260.0050.04312.72
5.3.250.0070.03712.72
5.3.240.0080.03612.72
5.3.230.0060.03912.71
5.3.220.0100.04712.68
5.3.210.0080.04412.68
5.3.200.0080.04512.68
5.3.190.0110.03712.68
5.3.180.0080.04412.67
5.3.170.0060.03812.67
5.3.160.0060.03712.67
5.3.150.0080.03512.67
5.3.140.0090.03812.66
5.3.130.0140.04112.65
5.3.120.0090.04612.66
5.3.110.0060.04512.66
5.3.100.0060.03912.13
5.3.90.0090.03712.11
5.3.80.0040.04712.11
5.3.70.0130.04312.10
5.3.60.0090.03912.09
5.3.50.0070.04412.03
5.3.40.0090.04412.03
5.3.30.0070.03411.99
5.3.20.0060.03511.78
5.3.10.0100.03211.74
5.3.00.0080.04311.73
5.2.170.0070.0339.23
5.2.160.0060.0389.23
5.2.150.0040.0329.23
5.2.140.0080.0329.23
5.2.130.0050.0289.19
5.2.120.0030.0319.18
5.2.110.0060.0289.19
5.2.100.0060.0289.19
5.2.90.0080.0339.20
5.2.80.0030.0329.19
5.2.70.0080.0289.19
5.2.60.0080.0279.14
5.2.50.0030.0349.11
5.2.40.0060.0389.08
5.2.30.0030.0419.06
5.2.20.0040.0379.05
5.2.10.0030.0358.95
5.2.00.0060.0358.82
5.1.60.0070.0328.10
5.1.50.0050.0298.10
5.1.40.0070.0318.08
5.1.30.0090.0298.43
5.1.20.0060.0278.45
5.1.10.0070.0288.18
5.1.00.0090.0268.18
5.0.50.0030.0216.66
5.0.40.0040.0206.52
5.0.30.0020.0346.33
5.0.20.0020.0246.30
5.0.10.0020.0266.28
5.0.00.0050.0356.27
4.4.90.0050.0164.78
4.4.80.0030.0174.76
4.4.70.0010.0194.75
4.4.60.0040.0154.76
4.4.50.0030.0164.77
4.4.40.0050.0234.71
4.4.30.0040.0144.76
4.4.20.0060.0144.84
4.4.10.0050.0234.85
4.4.00.0040.0284.76
4.3.110.0040.0184.66
4.3.100.0030.0154.66
4.3.90.0020.0154.64
4.3.80.0010.0314.58
4.3.70.0020.0164.63
4.3.60.0040.0164.63
4.3.50.0050.0174.62
4.3.40.0050.0274.54
4.3.30.0020.0163.32
4.3.20.0030.0213.29
4.3.10.0010.0173.25
4.3.00.0000.01714.30

preferences:
40.44 ms | 401 KiB | 5 Q