3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('json_encode')) { function json_encode($it) { if (!($assoc = is_object($it)) && !is_array($it)) { return _js_enc_value($it); } $i = 0; $it = (array)$it; if (!$assoc) { foreach ($it as $k => $v) { if ($k !== $i) { $assoc = true; break; } $i++; } } $data = array(); foreach ($it as $k => $v) { $v = _js_enc_value($v); if ($assoc) { $k = _js_enc_value($k); $data[] = $k . ':' . $v; } else { $data[] = $v; } } if ($assoc) { $bl = '{'; $br = '}'; } else { $bl = '['; $br = ']'; } return $bl . implode(',', $data) . $br; } function _js_enc_value($value) { switch (true) { case is_array($value): case is_object($value): return json_encode($value); case is_bool($value): return $value ? 'true' : 'false'; case $value === null: case is_resource($value) && _js_error(): return 'null'; case is_string($value): return '"' . _js_uc_esc($value) . '"'; default: return $value; } } function _js_error() { return trigger_error( 'json_encode(): type is unsupported, encoded as null', E_USER_WARNING ); } function _js_uc_esc($value) { $pattern = "@[\a\b\f\n\r\t\"'/]|([^\x09\x0A\x0D\x20-\x7E|]{3}|\\0|" . chr(11) . ")+@"; return preg_replace_callback($pattern, '_js_uc_esc_cb', $value); } function _js_uc_esc_cb($matches) { switch (true) { case isset($matches[1]): $char = mb_convert_encoding($matches[0], 'UTF-16', 'UTF-8'); $str = ''; $len = strlen($char); for ($i = 0; $i < $len; $i += 2) { $str .= sprintf('\\u%02x%02x', ord($char[$i]), ord($char[$i + 1]) ); } return $str; default: return addcslashes($matches[0], "\a\b\f\n\r\t\"'/"); } } } echo json_encode(array('&/"\''=>"\0\a\b\f\n\r\t" . chr(11)));

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.00318.31
8.3.50.0090.00921.21
8.3.40.0150.00018.80
8.3.30.0140.00020.21
8.3.20.0070.00020.20
8.3.10.0040.00421.97
8.3.00.0050.00322.43
8.2.180.0060.00916.75
8.2.170.0140.00022.96
8.2.160.0100.00322.11
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0040.00420.79
8.2.110.0070.00322.24
8.2.100.0150.00017.78
8.2.90.0040.00419.05
8.2.80.0040.00419.40
8.2.70.0030.00617.63
8.2.60.0040.00418.04
8.2.50.0050.00318.07
8.2.40.0030.00618.22
8.2.30.0040.00419.39
8.2.20.0000.00817.67
8.2.10.0040.00417.68
8.2.00.0040.00417.82
8.1.280.0140.00325.92
8.1.270.0040.00423.99
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00023.97
8.1.230.0080.00419.27
8.1.220.0000.00817.79
8.1.210.0040.00418.77
8.1.200.0000.00917.48
8.1.190.0000.00817.53
8.1.180.0000.00819.01
8.1.170.0040.00418.60
8.1.160.0040.00420.64
8.1.150.0030.00718.60
8.1.140.0040.00417.45
8.1.130.0070.00017.76
8.1.120.0040.00317.49
8.1.110.0070.00017.36
8.1.100.0080.00017.46
8.1.90.0020.00517.50
8.1.80.0000.00717.52
8.1.70.0000.00717.34
8.1.60.0060.00317.59
8.1.50.0040.00417.57
8.1.40.0040.00417.49
8.1.30.0000.00817.63
8.1.20.0040.00417.49
8.1.10.0040.00417.48
8.1.00.0000.00817.54
8.0.300.0040.00418.77
8.0.290.0070.00017.28
8.0.280.0070.00018.45
8.0.270.0000.00717.27
8.0.260.0000.00616.71
8.0.250.0030.00316.95
8.0.240.0050.00316.86
8.0.230.0000.00717.00
8.0.220.0000.00716.81
8.0.210.0000.00716.86
8.0.200.0030.00316.97
8.0.190.0050.00516.94
8.0.180.0000.00716.91
8.0.170.0000.00816.83
8.0.160.0040.00416.77
8.0.150.0000.00716.89
8.0.140.0070.00016.86
8.0.130.0060.00313.34
8.0.120.0000.00816.77
8.0.110.0040.00416.90
8.0.100.0040.00416.79
8.0.90.0040.00416.87
8.0.80.0100.01116.97
8.0.70.0040.00416.79
8.0.60.0020.00516.70
8.0.50.0050.00316.78
8.0.30.0150.00317.07
8.0.20.0070.01217.40
8.0.10.0000.00817.04
8.0.00.0160.00716.80
7.4.330.0060.00015.00
7.4.320.0000.00716.59
7.4.300.0000.00616.47
7.4.290.0000.00816.59
7.4.280.0000.00716.49
7.4.270.0070.00016.50
7.4.260.0050.00013.35
7.4.250.0000.00816.39
7.4.240.0070.00016.40
7.4.230.0030.00316.51
7.4.220.0090.00916.48
7.4.210.0070.00816.54
7.4.200.0070.00016.58
7.4.190.0040.00416.58
7.4.160.0060.00916.39
7.4.150.0080.00817.40
7.4.140.0090.00817.86
7.4.130.0060.01116.58
7.4.120.0070.01216.48
7.4.110.0070.01016.39
7.4.100.0100.00716.47
7.4.90.0160.00316.52
7.4.80.0130.00319.39
7.4.70.0150.00316.56
7.4.60.0080.00816.42
7.4.50.0070.00016.55
7.4.40.0000.01422.77
7.4.30.0080.00816.55
7.4.00.0090.00715.03
7.3.330.0000.00513.23
7.3.320.0000.00613.30
7.3.310.0020.00516.32
7.3.300.0030.00316.26
7.3.290.0070.01416.30
7.3.280.0090.00716.31
7.3.270.0060.01217.40
7.3.260.0140.00316.40
7.3.250.0080.00916.43
7.3.240.0090.00916.69
7.3.230.0110.00716.39
7.3.210.0160.00616.45
7.3.200.0100.00719.39
7.3.190.0160.00616.40
7.3.180.0080.00816.47
7.3.170.0060.01316.27
7.3.160.0150.00016.30
7.3.120.0080.00914.69
7.3.110.0140.00714.48
7.3.100.0140.00014.48
7.3.90.0090.00614.74
7.3.80.0050.00814.72
7.3.70.0040.01114.84
7.3.60.0100.00314.87
7.3.50.0060.00614.80
7.3.40.0000.01014.98
7.3.30.0060.00914.85
7.3.20.0030.01216.62
7.3.10.0070.01016.30
7.3.00.0130.00316.67
7.2.330.0070.01016.52
7.2.320.0120.00616.30
7.2.310.0150.00616.22
7.2.300.0130.00316.59
7.2.290.0070.01016.38
7.2.250.0060.01215.01
7.2.240.0060.00615.18
7.2.230.0030.01014.88
7.2.220.0060.00615.02
7.2.210.0060.00914.91
7.2.200.0070.00315.05
7.2.190.0070.01014.98
7.2.180.0070.01014.97
7.2.170.0070.00714.69
7.1.330.0140.00015.53
7.1.320.0090.00415.71
7.1.310.0030.01215.44
7.1.300.0030.01315.50
7.1.290.0110.00315.59
7.1.280.0000.01415.83
7.1.270.0030.01215.39
7.1.260.0030.01115.84
7.1.70.0030.00517.09
7.1.60.0110.01419.32
7.1.50.0040.01916.86
7.1.00.0000.03722.27
7.0.200.0000.00716.71
7.0.140.0100.06721.95
7.0.110.0470.05319.89
7.0.100.0030.09019.99
7.0.90.0030.08720.07
7.0.80.0000.06719.90
7.0.70.0030.04020.06
7.0.60.0000.04319.95
7.0.50.0000.04320.08
7.0.40.0030.04019.77
7.0.30.0030.08319.78
7.0.20.0070.07719.65
7.0.10.0100.04719.73
7.0.00.0070.05719.86
5.6.260.0130.07320.67
5.6.250.0130.06320.57
5.6.240.0100.08720.64
5.6.230.0070.07720.71
5.6.220.0030.04020.86
5.6.210.0030.03720.74
5.6.200.0170.02720.68
5.6.190.0030.07320.57
5.6.180.0070.06720.85
5.6.170.0070.07720.87
5.6.160.0100.05020.57
5.6.150.0130.07020.72
5.6.140.0100.04720.66
5.6.130.0130.06320.48
5.6.120.0030.06020.60
5.6.110.0130.03720.57
5.6.100.0000.04720.64
5.6.90.0030.03720.66
5.6.80.0070.06719.96
5.6.70.0000.05319.95
5.6.60.0030.04019.95
5.6.50.0000.04319.98
5.6.40.0000.04020.08
5.6.30.0030.04020.05
5.6.20.0030.04020.01
5.6.10.0100.03320.01
5.6.00.0030.05020.07
5.5.380.0100.07717.55
5.5.370.0000.08317.61
5.5.360.0030.04317.68
5.5.350.0070.03717.27
5.5.340.0100.03318.23
5.5.330.0030.07318.05
5.5.320.0070.03318.05
5.5.310.0030.06018.12
5.5.300.0000.08017.82
5.5.290.0130.05017.95
5.5.280.0000.05318.25
5.5.270.0070.04318.09
5.5.260.0030.04318.06
5.5.250.0030.04317.86
5.5.240.0070.03317.44
5.5.230.0000.04317.45
5.5.220.0030.04017.47
5.5.210.0030.03717.52
5.5.200.0030.06317.19
5.5.190.0070.03717.45
5.5.180.0030.04317.18
5.5.160.0030.04317.42
5.5.150.0030.04717.58
5.5.140.0000.04017.27
5.5.130.0000.04317.48
5.5.120.0000.04017.45
5.5.110.0000.05717.26
5.5.100.0070.06317.17
5.5.90.0030.06017.21
5.5.80.0030.07717.16
5.5.70.0070.04317.17
5.5.60.0070.07017.34
5.5.50.0070.07717.38
5.5.40.0030.04017.25
5.5.30.0100.06317.47
5.5.20.0070.07017.49
5.5.10.0030.03717.19
5.5.00.0030.03317.38
5.4.450.0070.04019.52
5.4.440.0070.04319.35
5.4.430.0070.04719.49
5.4.420.0070.06019.36
5.4.410.0030.05719.43
5.4.400.0070.05319.25
5.4.390.0000.04719.16
5.4.380.0000.04319.16
5.4.370.0070.03318.95
5.4.360.0070.04019.09
5.4.350.0000.04019.14
5.4.340.0100.03319.04
5.4.320.0030.04319.18
5.4.310.0130.06319.25
5.4.300.0130.05019.03
5.4.290.0030.04019.31
5.4.280.0130.02719.15
5.4.270.0070.03019.24
5.4.260.0130.06718.98
5.4.250.0070.06718.94
5.4.240.0000.04019.00
5.4.230.0030.03319.15
5.4.220.0030.07019.00
5.4.210.0100.07319.03
5.4.200.0100.07319.00
5.4.190.0000.04019.32
5.4.180.0100.06319.17
5.4.170.0070.03019.16
5.4.160.0100.05018.98
5.4.150.0030.06019.00
5.4.140.0070.06716.57
5.4.130.0100.05016.58
5.4.120.0030.05016.57
5.4.110.0030.07016.63
5.4.100.0030.04316.48
5.4.90.0070.07016.41
5.4.80.0030.03316.70
5.4.70.0000.07716.59
5.4.60.0100.05716.63
5.4.50.0030.07016.54
5.4.40.0070.07016.45
5.4.30.0130.07016.38
5.4.20.0130.05016.53
5.4.10.0130.07316.41
5.4.00.0100.07315.80
5.3.290.0070.03314.73
5.3.280.0030.04014.61
5.3.270.0070.06314.72
5.3.260.0100.07314.64
5.3.250.0070.07314.66
5.3.240.0000.04014.64
5.3.230.0070.08014.85
5.3.220.0000.03714.72
5.3.210.0070.06714.59
5.3.200.0030.03714.60
5.3.190.0070.07314.68
5.3.180.0130.06014.72
5.3.170.0070.07014.72
5.3.160.0000.03714.58
5.3.150.0030.07714.68
5.3.140.0070.07714.61
5.3.130.0130.07714.55
5.3.120.0100.06014.60
5.3.110.0130.07314.44
5.3.100.0070.07714.06
5.3.90.0030.07313.91
5.3.80.0070.06714.02
5.3.70.0130.07014.12
5.3.60.0070.07314.17
5.3.50.0100.06713.99
5.3.40.0100.06713.84
5.3.30.0070.05013.96
5.3.20.0030.07313.70
5.3.10.0030.07013.54
5.3.00.0100.07313.67
5.2.170.0100.05711.16
5.2.160.0100.04011.32
5.2.150.0000.04011.26
5.2.140.0030.03311.25
5.2.130.0130.05710.99
5.2.120.0030.07011.24
5.2.110.0070.06011.16
5.2.100.0170.05311.11
5.2.90.0100.05711.26
5.2.80.0070.06311.18
5.2.70.0100.06011.13
5.2.60.0030.06311.10
5.2.50.0070.06311.01
5.2.40.0000.05711.04
5.2.30.0070.05311.13
5.2.20.0070.05711.21
5.2.10.0030.05710.84
5.2.00.0070.06010.70
5.1.60.0070.05710.02
5.1.50.0030.06010.00
5.1.40.0070.0579.94
5.1.30.0070.06010.32
5.1.20.0030.05010.24
5.1.10.0000.06010.09
5.1.00.0130.03710.09
5.0.50.0070.0339.77
5.0.40.0070.0409.77
5.0.30.0130.0579.77
5.0.20.0030.0379.77
5.0.10.0030.0479.77
5.0.00.0070.0479.77
4.4.90.0000.0409.77
4.4.80.0030.0279.77
4.4.70.0070.0309.77
4.4.60.0070.0339.77
4.4.50.0030.0339.77
4.4.40.0070.0479.77
4.4.30.0030.0339.77
4.4.20.0000.0279.77
4.4.10.0030.0309.77
4.4.00.0030.0439.77
4.3.110.0070.0179.77
4.3.100.0000.0379.77
4.3.90.0100.0179.77
4.3.80.0000.0439.77
4.3.70.0030.0339.77
4.3.60.0030.0339.77
4.3.50.0030.0309.77
4.3.40.0000.0379.77
4.3.30.0030.0339.77
4.3.20.0000.0379.77
4.3.10.0000.0409.77
4.3.00.0070.0309.77

preferences:
41.87 ms | 401 KiB | 5 Q