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)
5.4.320.0030.03812.53
5.4.310.0070.03612.52
5.4.300.0060.03612.53
5.4.290.0040.05012.52
5.4.280.0050.04012.42
5.4.270.0080.03812.42
5.4.260.0040.04312.42
5.4.250.0050.04012.42
5.4.240.0070.03412.42
5.4.230.0050.03812.41
5.4.220.0040.04512.41
5.4.210.0060.03912.41
5.4.200.0100.03812.41
5.4.190.0060.03912.41
5.4.180.0120.03912.41
5.4.170.0080.03412.41
5.4.160.0010.04212.41
5.4.150.0070.03512.41
5.4.140.0100.03612.10
5.4.130.0060.03912.08
5.4.120.0020.03712.04
5.4.110.0030.04012.04
5.4.100.0040.03512.04
5.4.90.0060.04412.04
5.4.80.0030.04012.04
5.4.70.0070.03412.03
5.4.60.0090.04012.03
5.4.50.0120.03512.03
5.4.40.0060.03612.02
5.4.30.0060.04012.02
5.4.20.0080.03412.02
5.4.10.0060.03312.02
5.4.00.0080.03311.51
5.3.290.0090.03512.80
5.3.280.0070.03612.71
5.3.270.0050.03912.73
5.3.260.0030.04212.72
5.3.250.0030.04112.72
5.3.240.0040.03812.72
5.3.230.0060.03712.71
5.3.220.0040.03912.68
5.3.210.0040.04012.68
5.3.200.0110.05112.68
5.3.190.0050.03712.68
5.3.180.0070.03412.67
5.3.170.0120.04612.66
5.3.160.0060.04012.67
5.3.150.0040.04012.67
5.3.140.0060.04612.66
5.3.130.0090.03712.66
5.3.120.0070.03612.66
5.3.110.0070.03712.66
5.3.100.0080.04112.15
5.3.90.0080.03612.12
5.3.80.0030.04212.11
5.3.70.0080.04112.11
5.3.60.0050.03612.09
5.3.50.0070.03612.04
5.3.40.0030.04012.04
5.3.30.0050.03612.00
5.3.20.0050.03511.78
5.3.10.0060.03411.75
5.3.00.0060.03711.73
5.2.170.0040.0309.23
5.2.160.0030.0349.23
5.2.150.0040.0329.23
5.2.140.0050.0299.23
5.2.130.0050.0279.19
5.2.120.0050.0279.19
5.2.110.0030.0309.20
5.2.100.0040.0289.19
5.2.90.0030.0309.20
5.2.80.0090.0339.19
5.2.70.0070.0299.19
5.2.60.0080.0279.14
5.2.50.0040.0309.11
5.2.40.0040.0299.09
5.2.30.0050.0299.06
5.2.20.0050.0279.05
5.2.10.0040.0288.96
5.2.00.0040.0288.83
5.1.60.0020.0258.10
5.1.50.0030.0298.10
5.1.40.0060.0298.08
5.1.30.0060.0248.43
5.1.20.0110.0278.46
5.1.10.0070.0278.18
5.1.00.0060.0278.18
5.0.50.0050.0236.66
5.0.40.0030.0266.53
5.0.30.0040.0396.33
5.0.20.0050.0226.30
5.0.10.0050.0196.28
5.0.00.0020.0356.27
4.4.90.0040.0234.78
4.4.80.0070.0174.75
4.4.70.0060.0164.76
4.4.60.0050.0154.75
4.4.50.0030.0154.77
4.4.40.0030.0324.71
4.4.30.0030.0184.76
4.4.20.0040.0264.84
4.4.10.0020.0204.85
4.4.00.0020.0254.76
4.3.110.0050.0134.67
4.3.100.0030.0184.67
4.3.90.0030.0144.64
4.3.80.0030.0304.58
4.3.70.0020.0224.63
4.3.60.0030.0144.63
4.3.50.0030.0234.63
4.3.40.0050.0254.54
4.3.30.0030.0213.32
4.3.20.0020.0173.30
4.3.10.0030.0183.26
4.3.00.0130.01714.30

preferences:
143.1 ms | 1394 KiB | 7 Q