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.60.0110.00418.43
8.3.50.0110.00822.05
8.3.40.0100.01018.85
8.3.30.0110.00419.14
8.3.20.0060.00920.20
8.3.10.0080.00023.65
8.3.00.0080.00020.55
8.2.180.0150.00316.50
8.2.170.0090.00622.96
8.2.160.0160.00022.12
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0050.00221.11
8.2.110.0060.00322.24
8.2.100.0080.00317.91
8.2.90.0030.00519.17
8.2.80.0030.00517.97
8.2.70.0030.00617.50
8.2.60.0070.00417.80
8.2.50.0040.00418.07
8.2.40.0000.00818.04
8.2.30.0080.00017.99
8.2.20.0040.00417.63
8.2.10.0000.00717.55
8.2.00.0000.00717.55
8.1.280.0140.00325.92
8.1.270.0000.00823.70
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00720.87
8.1.230.0000.01117.42
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0030.00617.23
8.1.190.0000.00817.53
8.1.180.0060.00318.10
8.1.170.0050.00318.31
8.1.160.0000.00721.97
8.1.150.0040.00418.53
8.1.140.0000.00817.45
8.1.130.0000.00717.81
8.1.120.0000.00717.36
8.1.110.0030.00517.46
8.1.100.0080.00017.44
8.1.90.0040.00417.34
8.1.80.0000.00717.36
8.1.70.0030.00317.34
8.1.60.0040.00417.48
8.1.50.0060.00317.50
8.1.40.0040.00417.55
8.1.30.0040.00417.60
8.1.20.0030.00617.63
8.1.10.0060.00317.52
8.1.00.0040.00417.43
8.0.300.0020.00518.77
8.0.290.0070.00016.88
8.0.280.0040.00418.46
8.0.270.0080.00017.18
8.0.260.0030.00316.78
8.0.250.0070.00016.96
8.0.240.0070.00016.96
8.0.230.0030.00316.95
8.0.220.0030.00316.77
8.0.210.0040.00416.78
8.0.200.0030.00316.96
8.0.190.0000.00716.83
8.0.180.0050.00216.92
8.0.170.0040.00416.83
8.0.160.0000.00816.79
8.0.150.0050.00216.73
8.0.140.0040.00416.74
8.0.130.0030.00313.34
8.0.120.0000.00816.78
8.0.110.0000.00816.79
8.0.100.0040.00416.84
8.0.90.0000.00716.88
8.0.80.0030.01216.90
8.0.70.0070.00016.80
8.0.60.0070.00016.77
8.0.50.0000.00716.69
8.0.30.0110.01017.07
8.0.20.0080.01017.40
8.0.10.0040.00416.93
8.0.00.0070.01316.67
7.4.330.0000.00515.00
7.4.320.0030.00316.61
7.4.300.0030.00316.50
7.4.290.0020.00516.61
7.4.280.0050.00316.41
7.4.270.0030.00316.55
7.4.260.0070.00416.61
7.4.250.0070.00016.55
7.4.240.0050.00316.53
7.4.230.0080.00016.34
7.4.220.0030.01516.62
7.4.210.0110.00316.44
7.4.200.0040.00416.35
7.4.190.0000.00716.67
7.4.160.0080.00816.48
7.4.150.0070.01017.40
7.4.140.0140.00617.86
7.4.130.0150.00716.51
7.4.120.0100.00816.49
7.4.110.0120.00616.49
7.4.100.0050.01216.45
7.4.90.0060.01216.66
7.4.80.0060.01316.33
7.4.70.0130.00316.43
7.4.60.0070.01016.44
7.4.50.0040.00016.32
7.4.40.0100.00722.77
7.4.30.0090.00816.49
7.4.10.0060.01214.99
7.4.00.0070.00714.86
7.3.330.0000.00613.24
7.3.320.0050.00013.22
7.3.310.0050.00316.29
7.3.300.0040.00416.25
7.3.290.0110.00316.26
7.3.280.0080.00916.25
7.3.270.0120.00617.40
7.3.260.0030.01416.14
7.3.250.0050.01316.34
7.3.240.0120.00616.37
7.3.230.0100.01016.45
7.3.210.0100.01016.20
7.3.200.0060.01219.39
7.3.190.0070.01016.53
7.3.180.0060.00916.32
7.3.170.0120.00316.27
7.3.160.0120.00316.59
7.3.130.0070.01014.54
7.3.120.0080.00814.70
7.3.110.0100.00314.60
7.3.100.0100.00314.50
7.3.90.0100.00614.61
7.3.80.0040.00914.98
7.3.70.0140.00314.82
7.3.60.0100.00414.80
7.3.50.0090.00614.64
7.3.40.0060.00314.43
7.3.30.0090.00914.73
7.3.20.0140.00316.50
7.3.10.0020.00916.52
7.3.00.0060.00416.48
7.2.330.0130.00516.27
7.2.320.0150.00316.19
7.2.310.0100.00716.45
7.2.300.0170.00016.57
7.2.290.0160.00316.41
7.2.260.0080.00814.89
7.2.250.0000.01714.86
7.2.240.0030.01114.91
7.2.230.0120.00414.60
7.2.220.0100.00314.57
7.2.210.0070.00715.00
7.2.200.0060.00914.89
7.2.190.0090.00615.05
7.2.180.0030.01014.61
7.2.170.0100.00714.82
7.2.160.0070.01014.54
7.2.150.0070.00716.50
7.2.140.0080.00516.68
7.2.130.0020.01116.94
7.2.120.0070.00716.86
7.2.110.0100.00316.81
7.2.100.0040.00716.75
7.2.90.0030.01016.89
7.2.80.0080.00816.75
7.2.70.0060.00516.64
7.2.60.0030.01016.77
7.2.50.0060.00616.82
7.2.40.0050.00716.77
7.2.30.0030.01016.69
7.2.20.0030.01116.76
7.2.10.0080.00616.68
7.2.00.0050.01016.83
7.1.330.0000.01415.29
7.1.320.0070.00415.57
7.1.310.0030.00915.84
7.1.300.0000.01415.61
7.1.290.0060.00315.59
7.1.280.0060.01015.79
7.1.270.0060.01015.53
7.1.260.0070.00715.44
7.1.250.0090.00515.66
7.1.240.0060.00315.69
7.1.230.0040.00815.72
7.1.220.0060.00615.49
7.1.210.0030.00715.66
7.1.200.0000.01215.49
7.1.190.0030.00715.87
7.1.180.0060.00315.35
7.1.170.0030.00715.57
7.1.160.0060.00615.44
7.1.150.0030.01015.73
7.1.140.0070.00715.72
7.1.130.0060.00615.49
7.1.120.0000.01515.57
7.1.110.0110.00415.86
7.1.100.0060.00915.77
7.1.90.0060.00615.77
7.1.80.0030.01015.54
7.1.70.0060.00416.15
7.1.60.0060.01017.56
7.1.50.0050.01216.37
7.1.40.0030.00915.73
7.1.30.0030.00615.32
7.1.20.0000.01415.78
7.1.10.0070.01015.61
7.1.00.0080.03819.05
7.0.330.0030.01215.14
7.0.320.0060.00615.58
7.0.310.0080.00515.25
7.0.300.0040.00815.23
7.0.290.0030.00615.38
7.0.280.0100.00615.30
7.0.270.0040.00715.37
7.0.260.0030.01315.35
7.0.250.0080.00815.13
7.0.240.0070.00715.58
7.0.230.0030.01215.35
7.0.220.0030.01015.20
7.0.210.0060.00615.39
7.0.200.0100.00416.14
7.0.190.0070.00715.48
7.0.180.0090.00015.45
7.0.170.0060.00315.40
7.0.160.0100.00315.09
7.0.150.0120.00315.32
7.0.140.0100.03618.68
7.0.130.0090.00615.41
7.0.120.0090.00415.22
7.0.110.0040.01115.19
7.0.100.0060.00315.30
7.0.90.0120.04017.72
7.0.80.0070.03417.69
7.0.70.0350.04317.63
7.0.60.0280.04017.65
7.0.50.0280.02817.79
7.0.40.0040.03116.73
7.0.30.0120.04316.73
7.0.20.0050.02716.84
7.0.10.0070.04516.77
7.0.00.0100.04216.68
5.6.400.0000.01014.37
5.6.390.0090.00614.28
5.6.380.0000.01114.29
5.6.370.0110.00413.86
5.6.360.0110.00414.48
5.6.350.0000.00914.57
5.6.340.0060.00914.36
5.6.330.0000.01314.08
5.6.320.0040.01114.23
5.6.310.0030.00714.25
5.6.300.0030.00613.94
5.6.290.0110.00314.50
5.6.280.0020.04517.86
5.6.270.0030.01014.59
5.6.260.0060.00614.33
5.6.250.0030.00914.17
5.6.240.0070.03717.53
5.6.230.0080.04017.36
5.6.220.0060.02917.52
5.6.210.0030.04317.52
5.6.200.0050.02517.70
5.6.190.0110.04117.74
5.6.180.0050.04617.66
5.6.170.0050.04517.61
5.6.160.0080.02517.58
5.6.150.0130.02317.79
5.6.140.0090.04117.64
5.6.130.0070.04417.63
5.6.120.0130.03917.80
5.6.110.0050.03017.78
5.6.100.0050.04717.54
5.6.90.0130.03717.71
5.6.80.0100.04117.26
5.6.70.0090.03117.29
5.6.60.0090.02317.26
5.6.50.0080.04517.15
5.6.40.0040.03817.29
5.6.30.0010.04117.55
5.6.20.0030.03317.32
5.6.10.0090.03617.28
5.6.00.0090.04117.38
5.5.380.0040.04917.40
5.5.370.0100.03917.37
5.5.360.0070.04217.21
5.5.350.0080.04217.46
5.5.340.0020.03517.59
5.5.330.0070.03117.56
5.5.320.0050.03017.62
5.5.310.0030.03417.55
5.5.300.0070.04817.35
5.5.290.0030.04717.47
5.5.280.0070.04917.55
5.5.270.0170.04217.49
5.5.260.0080.03317.53
5.5.250.0050.03417.47
5.5.240.0100.03917.07
5.5.230.0040.04617.11
5.5.220.0070.02517.10
5.5.210.0070.02317.20
5.5.200.0020.03917.15
5.5.190.0030.03317.32
5.5.180.0060.03617.29
5.5.170.0000.00914.03
5.5.160.0070.03017.23
5.5.150.0090.03017.23
5.5.140.0070.03817.20
5.5.130.0050.03017.39
5.5.120.0070.04417.27
5.5.110.0030.03517.24
5.5.100.0040.04517.24
5.5.90.0100.04017.15
5.5.80.0080.02417.20
5.5.70.0020.03817.24
5.5.60.0070.02617.14
5.5.50.0120.03017.07
5.5.40.0100.03417.21
5.5.30.0100.03916.90
5.5.20.0030.03317.08
5.5.10.0070.04216.99
5.5.00.0120.04017.19
5.4.450.0110.04015.80
5.4.440.0020.03115.85
5.4.430.0030.04015.82
5.4.420.0080.04015.80
5.4.410.0070.04315.64
5.4.400.0130.03715.56
5.4.390.0030.04415.72
5.4.380.0050.03915.56
5.4.370.0030.02515.73
5.4.360.0070.03515.56
5.4.350.0160.03315.68
5.4.340.0050.02715.56
5.4.330.0090.00012.24
5.4.320.0050.04315.64
5.4.310.0070.03815.56
5.4.300.0070.04215.56
5.4.290.0020.04915.56
5.4.280.0100.03815.67
5.4.270.0070.03915.67
5.4.260.0080.03315.58
5.4.250.0110.03015.72
5.4.240.0070.03815.63
5.4.230.0080.02515.71
5.4.220.0100.03815.55
5.4.210.0080.03915.63
5.4.200.0070.04015.67
5.4.190.0060.03315.56
5.4.180.0080.03815.57
5.4.170.0050.03415.72
5.4.160.0020.04415.66
5.4.150.0090.03515.70
5.4.140.0090.02314.33
5.4.130.0050.03114.37
5.4.120.0050.04014.21
5.4.110.0060.02314.34
5.4.100.0070.02814.40
5.4.90.0050.02814.32
5.4.80.0050.03614.38
5.4.70.0080.02014.32
5.4.60.0050.02814.35
5.4.50.0050.04114.36
5.4.40.0080.02114.31
5.4.30.0070.03814.33
5.4.20.0070.03714.37
5.4.10.0050.02814.27
5.4.00.0050.04113.98
5.3.290.0040.04013.45
5.3.280.0050.04413.43
5.3.270.0050.03013.42
5.3.260.0130.02313.42
5.3.250.0090.03513.43
5.3.240.0080.03513.49
5.3.230.0050.04013.47
5.3.220.0000.03413.45
5.3.210.0020.03613.46
5.3.200.0060.04313.45
5.3.190.0060.03013.42
5.3.180.0060.02513.43
5.3.170.0070.03713.44
5.3.160.0070.03313.41
5.3.150.0080.04013.44
5.3.140.0090.03513.38
5.3.130.0020.03213.45
5.3.120.0020.03913.38
5.3.110.0080.03613.44
5.3.100.0050.04113.13
5.3.90.0000.04213.11
5.3.80.0020.02913.08
5.3.70.0070.01913.09
5.3.60.0040.02313.15
5.3.50.0050.02813.14
5.3.40.0020.03913.11
5.3.30.0050.03913.13
5.3.20.0050.03813.04
5.3.10.0030.02313.01
5.3.00.0040.02413.01
5.2.170.0100.04711.07
5.2.160.0070.05711.11
5.2.150.0000.06711.11
5.2.140.0000.04011.08
5.2.130.0000.03711.24
5.2.120.0130.05311.15
5.2.110.0130.03311.15
5.2.100.0000.03311.21
5.2.90.0100.02311.02
5.2.80.0030.04311.23
5.2.70.0130.04310.98
5.2.60.0030.04711.02
5.2.50.0100.06010.98
5.2.40.0070.06010.93
5.2.30.0000.04310.88
5.2.20.0070.04011.04
5.2.10.0000.04011.02
5.2.00.0000.05010.78
5.1.60.0000.05710.08
5.1.50.0000.04310.09
5.1.40.0000.05010.05
5.1.30.0070.04010.47
5.1.20.0000.04010.49
5.1.10.0030.03710.11
5.1.00.0030.04710.20
5.0.50.0070.0408.44
5.0.40.0030.0308.46
5.0.30.0000.0638.38
5.0.20.0030.0478.23
5.0.10.0000.0478.10
5.0.00.0070.0578.27
4.4.90.0000.0377.22
4.4.80.0000.0237.22
4.4.70.0000.0407.22
4.4.60.0000.0377.22
4.4.50.0000.0337.22
4.4.40.0000.0407.22
4.4.30.0070.0337.22
4.4.20.0070.0337.22
4.4.10.0000.0337.22
4.4.00.0000.0537.22
4.3.110.0030.0207.22
4.3.100.0000.0377.22
4.3.90.0000.0377.22
4.3.80.0000.0337.22
4.3.70.0070.0307.22
4.3.60.0030.0237.22
4.3.50.0030.0177.22
4.3.40.0070.0207.22
4.3.30.0000.0177.22
4.3.20.0030.0137.22
4.3.10.0030.0177.22
4.3.00.0030.0277.22

preferences:
45.66 ms | 400 KiB | 5 Q