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 = '"'. addcslashes($k, '"\\') . '"'; $data[] = $k . ':' . $v; } else { $data[] = $v; } } if ($assoc) { $spl = '{'; $spr = '}'; } else { $spl = '['; $spr = ']'; } return $spl . implode(',', $data) . $spr; } 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 = "/\r|(\n)|((?:[^\x09\x0A\x0D\x20-\x7E]{3})+)/"; return preg_replace_callback($pattern, '_js_uc_esc_cb', $value); } function _js_uc_esc_cb($matches) { switch (true) { case isset($matches[2]): $char = mb_convert_encoding($matches[2], '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; case isset($matches[1]): return '\\n'; default: return '\\r'; } } } echo json_encode(array('<'));

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.40.0140.00018.79
8.3.30.0110.00318.81
8.3.20.0000.00720.28
8.3.10.0030.00623.53
8.3.00.0000.00820.58
8.2.170.0130.00722.96
8.2.160.0000.01522.15
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0050.00326.16
8.2.120.0040.00417.50
8.2.110.0090.00022.06
8.2.100.0000.01117.53
8.2.90.0050.00219.08
8.2.80.0040.00417.97
8.2.70.0030.00717.50
8.2.60.0000.00817.80
8.2.50.0040.00418.07
8.2.40.0000.01018.21
8.2.30.0030.00618.11
8.2.20.0070.00017.55
8.2.10.0080.00017.66
8.2.00.0090.00017.72
8.1.270.0030.00523.84
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0060.00323.89
8.1.230.0030.00820.95
8.1.220.0030.00617.74
8.1.210.0080.00018.77
8.1.200.0000.00817.22
8.1.190.0060.00317.40
8.1.180.0030.00518.10
8.1.170.0090.00018.59
8.1.160.0040.00422.04
8.1.150.0000.00818.61
8.1.140.0000.00717.41
8.1.130.0090.00019.17
8.1.120.0050.00217.50
8.1.110.0000.00817.42
8.1.100.0040.00417.42
8.1.90.0100.00017.43
8.1.80.0000.00717.45
8.1.70.0030.00317.45
8.1.60.0050.00317.45
8.1.50.0040.00417.41
8.1.40.0040.00417.52
8.1.30.0040.00417.51
8.1.20.0050.00317.64
8.1.10.0000.00717.57
8.1.00.0030.00517.47
8.0.300.0000.00718.77
8.0.290.0000.00817.18
8.0.280.0000.00718.49
8.0.270.0040.00417.94
8.0.260.0030.00316.86
8.0.250.0030.00316.86
8.0.240.0080.00016.96
8.0.230.0000.00716.84
8.0.220.0000.00716.88
8.0.210.0000.00716.84
8.0.200.0030.00316.96
8.0.190.0040.00416.91
8.0.180.0030.00716.79
8.0.170.0000.00716.92
8.0.160.0070.00016.77
8.0.150.0000.00716.79
8.0.140.0000.00816.71
8.0.130.0030.00313.36
8.0.120.0050.00216.92
8.0.110.0040.00416.90
8.0.100.0040.00416.95
8.0.90.0040.00416.86
8.0.80.0150.00416.80
8.0.70.0070.00016.91
8.0.60.0040.00416.76
8.0.50.0040.00416.89
8.0.30.0180.00317.15
8.0.20.0110.00817.40
8.0.10.0070.00016.85
8.0.00.0110.00816.76
7.4.330.0030.00315.00
7.4.320.0030.00316.52
7.4.300.0030.00316.42
7.4.290.0040.00416.50
7.4.280.0070.00016.51
7.4.270.0070.00016.61
7.4.260.0030.00316.62
7.4.250.0040.00416.42
7.4.240.0020.00616.47
7.4.230.0030.00316.50
7.4.220.0160.01016.53
7.4.210.0090.00616.50
7.4.200.0000.00816.34
7.4.190.0040.00416.59
7.4.160.0030.01316.57
7.4.150.0060.01317.40
7.4.140.0050.01217.86
7.4.130.0090.00816.42
7.4.120.0090.00916.46
7.4.110.0130.00716.58
7.4.100.0120.00616.67
7.4.90.0100.00716.52
7.4.80.0040.01816.48
7.4.70.0160.00016.37
7.4.60.0080.00816.43
7.4.50.0030.00616.21
7.4.40.0080.00822.77
7.4.30.0080.00816.51
7.4.00.0040.01414.66
7.3.330.0030.00313.26
7.3.320.0050.00013.20
7.3.310.0070.00016.14
7.3.300.0020.00516.29
7.3.290.0040.01116.21
7.3.280.0120.00816.21
7.3.270.0100.01017.40
7.3.260.0030.01516.54
7.3.250.0070.01016.34
7.3.240.0140.00416.35
7.3.230.0100.01016.39
7.3.210.0120.00616.39
7.3.200.0110.01119.39
7.3.190.0130.01016.61
7.3.180.0140.00716.39
7.3.170.0120.00316.39
7.3.160.0130.00516.29
7.3.120.0060.01214.77
7.2.330.0090.00916.71
7.2.320.0120.00816.26
7.2.310.0100.00616.49
7.2.300.0070.01216.57
7.2.290.0070.01016.69
7.2.00.0030.01418.96
7.1.100.0040.00718.11
7.1.70.0110.00716.70
7.1.60.0040.00817.09
7.1.50.0070.00716.69
7.1.00.0030.07722.43
7.0.200.0000.01116.73
7.0.140.0100.06322.08
7.0.90.0530.08720.04
7.0.80.0500.06319.94
7.0.70.0330.05319.93
7.0.60.0530.09020.00
7.0.50.0430.05320.17
7.0.40.0170.07319.91
7.0.30.0070.08020.19
7.0.20.0170.07720.04
7.0.10.0030.06720.07
7.0.00.0030.08320.09
5.6.280.0070.07320.88
5.6.240.0170.06020.62
5.6.230.0130.08020.55
5.6.220.0070.07020.73
5.6.210.0070.07720.66
5.6.200.0130.08021.07
5.6.190.0200.07721.07
5.6.180.0130.06021.07
5.6.170.0070.08021.05
5.6.160.0130.06721.12
5.6.150.0030.08321.08
5.6.140.0100.08721.02
5.6.130.0070.09020.94
5.6.120.0000.09321.15
5.6.110.0130.06721.04
5.6.100.0070.07321.09
5.6.90.0130.08021.10
5.6.80.0070.07720.40
5.6.70.0070.04020.40
5.6.60.0230.06720.52
5.6.50.0030.06020.57
5.6.40.0070.07320.45
5.6.30.0030.06320.48
5.6.20.0030.07720.47
5.6.10.0070.06320.53
5.6.00.0130.07320.38
5.5.380.0130.03720.47
5.5.370.0130.06720.37
5.5.360.0100.04320.38
5.5.350.0030.06320.43
5.5.340.0070.04020.91
5.5.330.0030.07320.78
5.5.320.0130.06320.89
5.5.310.0130.05020.93
5.5.300.0070.06320.66
5.5.290.0100.08320.85
5.5.280.0200.07320.81
5.5.270.0270.06320.77
5.5.260.0130.06720.89
5.5.250.0100.08020.59
5.5.240.0070.05720.30
5.5.230.0070.08020.30
5.5.220.0070.07320.18
5.5.210.0100.06320.13
5.5.200.0170.06720.14
5.5.190.0070.04720.29
5.5.180.0100.07720.10
5.5.160.0130.06020.24
5.5.150.0100.07320.09
5.5.140.0130.07020.18
5.5.130.0100.07020.14
5.5.120.0130.06720.25
5.5.110.0130.06320.16
5.5.100.0230.04320.09
5.5.90.0130.04320.11
5.5.80.0030.07720.05
5.5.70.0100.05320.08
5.5.60.0030.07320.11
5.5.50.0030.07320.16
5.5.40.0100.05720.18
5.5.30.0030.07319.95
5.5.20.0070.08320.09
5.5.10.0100.08020.13
5.5.00.0100.07320.15
5.4.450.0130.07019.57
5.4.440.0130.07319.20
5.4.430.0100.06319.47
5.4.420.0030.05019.45
5.4.410.0200.06719.24
5.4.400.0070.07719.04
5.4.390.0100.07718.95
5.4.380.0130.06319.13
5.4.370.0070.06718.91
5.4.360.0070.06718.95
5.4.350.0130.07018.95
5.4.340.0030.08019.03
5.4.320.0030.07019.16
5.4.310.0130.06319.23
5.4.300.0130.05719.16
5.4.290.0070.07719.18
5.4.280.0200.06319.05
5.4.270.0170.05318.84
5.4.260.0000.08318.94
5.4.250.0100.07318.94
5.4.240.0100.07718.87
5.4.230.0070.07318.87
5.4.220.0100.06718.94
5.4.210.0100.08019.22
5.4.200.0030.07719.12
5.4.190.0070.06019.01
5.4.180.0030.07018.84
5.4.170.0070.07719.02
5.4.160.0030.05318.86
5.4.150.0070.05019.02
5.4.140.0100.05016.44
5.4.130.0130.06716.43
5.4.120.0070.07016.34
5.4.110.0070.07316.45
5.4.100.0170.06016.55
5.4.90.0100.06716.56
5.4.80.0070.07016.41
5.4.70.0000.07016.40
5.4.60.0070.07016.32
5.4.50.0070.06316.36
5.4.40.0070.07016.51
5.4.30.0130.07016.33
5.4.20.0100.06716.30
5.4.10.0070.05016.30
5.4.00.0100.07015.83
5.3.290.0070.07714.70
5.3.280.0130.07014.57
5.3.270.0070.07014.64
5.3.260.0030.07014.77
5.3.250.0030.07314.70
5.3.240.0100.07714.66
5.3.230.0100.06314.76
5.3.220.0130.05714.73
5.3.210.0030.07714.70
5.3.200.0100.06714.62
5.3.190.0070.05014.71
5.3.180.0000.05014.68
5.3.170.0030.08014.51
5.3.160.0030.08014.57
5.3.150.0070.08014.71
5.3.140.0030.08314.64
5.3.130.0030.08014.56
5.3.120.0030.06714.64
5.3.110.0070.07714.59
5.3.100.0100.06314.08
5.3.90.0070.04713.97
5.3.80.0100.07013.98
5.3.70.0000.08314.17
5.3.60.0130.06714.04
5.3.50.0070.05014.06
5.3.40.0000.06714.10
5.3.30.0130.07014.05
5.3.20.0130.06713.63
5.3.10.0030.07013.75
5.3.00.0070.07013.62
5.2.170.0070.06311.08
5.2.160.0030.06311.04
5.2.150.0070.04711.32
5.2.140.0030.06711.09
5.2.130.0030.06711.04
5.2.120.0130.05311.26
5.2.110.0070.05711.15
5.2.100.0100.05711.02
5.2.90.0030.06011.22
5.2.80.0030.03311.05
5.2.70.0030.06310.98
5.2.60.0100.05010.95
5.2.50.0070.05711.09
5.2.40.0070.05311.09
5.2.30.0000.06311.01
5.2.20.0000.06010.97
5.2.10.0000.06310.89
5.2.00.0070.04710.75
5.1.60.0070.05010.02
5.1.50.0030.0539.87
5.1.40.0000.05010.07
5.1.30.0070.05010.38
5.1.20.0000.06010.48
5.1.10.0130.0439.95
5.1.00.0070.05310.16
5.0.50.0000.0508.69
5.0.40.0070.0438.53
5.0.30.0030.0608.35
5.0.20.0000.0408.32
5.0.10.0030.0438.32
5.0.00.0100.0508.25
4.4.90.0000.0377.37
4.4.80.0000.0407.37
4.4.70.0030.0377.37
4.4.60.0030.0277.37
4.4.50.0030.0337.37
4.4.40.0000.0377.37
4.4.30.0030.0337.37
4.4.20.0000.0377.37
4.4.10.0000.0337.37
4.4.00.0000.0477.37
4.3.110.0000.0337.37
4.3.100.0000.0337.37
4.3.90.0030.0307.37
4.3.80.0000.0577.37
4.3.70.0070.0337.37
4.3.60.0030.0237.37
4.3.50.0000.0377.37
4.3.40.0000.0477.37
4.3.30.0030.0337.37
4.3.20.0030.0337.37
4.3.10.0030.0337.37
4.3.00.0000.0377.37

preferences:
41.05 ms | 400 KiB | 5 Q