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[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], "\r\n\"'/"); } } } 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.0180.00016.75
8.3.50.0130.00922.07
8.3.40.0070.00718.75
8.3.30.0110.00718.98
8.3.20.0040.00420.21
8.3.10.0000.00823.66
8.3.00.0040.00420.68
8.2.180.0090.00616.38
8.2.170.0040.01122.96
8.2.160.0060.00922.25
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00419.64
8.2.110.0090.00022.07
8.2.100.0060.00617.59
8.2.90.0000.00819.05
8.2.80.0080.00017.97
8.2.70.0000.00817.50
8.2.60.0040.00417.80
8.2.50.0000.00918.07
8.2.40.0040.00419.23
8.2.30.0040.00417.97
8.2.20.0040.00417.57
8.2.10.0000.00817.68
8.2.00.0020.00517.72
8.1.280.0100.00325.92
8.1.270.0040.00423.84
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0090.00023.82
8.1.230.0080.00419.00
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0030.00617.22
8.1.190.0040.00417.16
8.1.180.0040.00418.10
8.1.170.0000.00818.57
8.1.160.0050.00221.99
8.1.150.0000.00718.68
8.1.140.0040.00417.39
8.1.130.0080.00017.70
8.1.120.0000.00717.45
8.1.110.0020.00517.44
8.1.100.0050.00217.38
8.1.90.0090.00017.42
8.1.80.0040.00417.45
8.1.70.0000.00717.37
8.1.60.0030.00517.40
8.1.50.0040.00417.39
8.1.40.0040.00417.55
8.1.30.0040.00417.62
8.1.20.0040.00417.47
8.1.10.0080.00017.48
8.1.00.0040.00417.46
8.0.300.0050.00318.77
8.0.290.0040.00417.28
8.0.280.0030.00318.35
8.0.270.0070.00017.27
8.0.260.0050.00218.51
8.0.250.0040.00317.00
8.0.240.0080.00016.98
8.0.230.0040.00416.89
8.0.220.0000.00716.90
8.0.210.0040.00416.91
8.0.200.0000.00816.79
8.0.190.0000.00816.93
8.0.180.0040.00416.86
8.0.170.0030.00516.90
8.0.160.0050.00216.77
8.0.150.0000.00716.78
8.0.140.0000.00716.76
8.0.130.0030.00313.31
8.0.120.0040.00416.83
8.0.110.0040.00416.78
8.0.100.0060.00317.00
8.0.90.0070.00016.79
8.0.80.0120.00616.88
8.0.70.0040.00416.80
8.0.60.0000.00716.93
8.0.50.0000.00816.86
8.0.30.0120.00817.12
8.0.20.0090.01017.40
8.0.10.0060.00316.96
8.0.00.0100.00816.82
7.4.330.0030.00315.07
7.4.320.0030.00316.40
7.4.300.0030.00316.57
7.4.290.0000.00716.51
7.4.280.0000.00816.59
7.4.270.0070.00016.51
7.4.260.0080.00016.54
7.4.250.0060.00316.27
7.4.240.0000.00716.47
7.4.230.0000.00716.67
7.4.220.0070.01116.38
7.4.210.0060.00816.43
7.4.200.0000.00716.55
7.4.190.0040.00416.66
7.4.160.0040.01616.47
7.4.150.0130.00617.40
7.4.140.0120.00917.86
7.4.130.0110.00616.54
7.4.120.0060.01116.48
7.4.110.0070.01016.55
7.4.100.0140.00816.51
7.4.90.0140.00716.38
7.4.80.0100.01316.48
7.4.70.0030.01316.46
7.4.60.0040.01616.43
7.4.50.0030.00616.45
7.4.40.0000.01722.77
7.4.30.0080.00816.38
7.4.10.0000.01916.36
7.4.00.0080.01015.58
7.3.330.0030.00313.26
7.3.320.0020.00213.24
7.3.310.0000.00716.05
7.3.300.0030.00316.29
7.3.290.0070.01316.23
7.3.280.0100.00816.26
7.3.270.0080.00817.40
7.3.260.0130.00316.52
7.3.250.0150.00416.40
7.3.240.0090.00916.37
7.3.230.0070.01016.39
7.3.210.0130.00716.39
7.3.200.0110.01119.39
7.3.190.0170.00916.29
7.3.180.0030.01316.63
7.3.170.0090.00616.48
7.3.160.0030.01616.33
7.3.130.0060.01416.40
7.3.120.0080.00915.26
7.3.110.0090.00715.61
7.3.100.0090.00715.73
7.3.90.0090.00515.32
7.3.80.0060.00515.68
7.3.70.0060.00615.39
7.3.60.0050.00815.58
7.3.50.0050.00815.48
7.3.40.0050.00815.45
7.3.30.0050.00915.54
7.3.20.0040.01417.20
7.3.10.0090.00716.82
7.3.00.0040.00816.72
7.2.330.0140.00316.26
7.2.320.0090.00916.65
7.2.310.0060.01616.18
7.2.300.0100.01316.40
7.2.290.0030.01216.57
7.2.260.0090.00916.63
7.2.250.0060.01115.78
7.2.240.0050.01215.57
7.2.230.0060.00615.53
7.2.220.0090.00515.82
7.2.210.0090.00115.60
7.2.200.0060.00815.62
7.2.190.0030.01015.69
7.2.180.0040.01115.70
7.2.170.0040.01115.63
7.2.160.0000.01916.52
7.2.150.0070.01018.38
7.2.140.0070.01018.25
7.2.130.0090.00717.01
7.2.120.0080.00717.01
7.2.110.0050.00917.00
7.2.100.0050.00817.06
7.2.90.0100.00717.02
7.2.80.0070.00917.04
7.2.70.0060.01017.16
7.2.60.0080.00817.13
7.2.50.0050.01116.95
7.2.40.0080.01017.02
7.2.30.0070.00717.06
7.2.20.0060.00917.14
7.2.10.0070.00917.08
7.2.00.0080.00717.51
7.1.330.0070.00816.28
7.1.320.0020.01316.41
7.1.310.0080.00816.33
7.1.300.0080.00416.46
7.1.290.0040.01016.40
7.1.280.0050.00716.44
7.1.270.0100.00716.38
7.1.260.0120.00316.42
7.1.250.0080.00515.98
7.1.240.0040.01417.15
7.1.230.0030.00717.12
7.1.220.0080.00817.20
7.1.210.0140.00317.20
7.1.200.0100.00317.20
7.1.190.0040.01117.04
7.1.180.0130.00317.19
7.1.170.0160.00317.22
7.1.160.0030.00917.30
7.1.150.0040.01117.14
7.1.140.0070.00717.22
7.1.130.0030.01317.32
7.1.120.0080.00417.15
7.1.110.0030.00917.13
7.1.100.0050.00517.52
7.1.90.0060.00917.26
7.1.80.0080.00817.22
7.1.70.0060.00716.96
7.1.60.0050.01318.25
7.1.50.0100.00416.98
7.1.40.0090.00617.36
7.1.30.0070.00717.23
7.1.20.0060.00617.15
7.1.10.0120.00317.36
7.1.00.0030.04319.84
7.0.330.0070.00716.79
7.0.320.0070.01016.86
7.0.310.0040.01116.92
7.0.300.0040.01116.88
7.0.290.0030.01016.99
7.0.280.0030.01716.89
7.0.270.0030.00617.03
7.0.260.0040.00416.82
7.0.250.0030.01016.91
7.0.240.0030.00617.03
7.0.230.0030.00617.06
7.0.220.0040.01516.88
7.0.210.0070.00716.88
7.0.200.0080.00216.81
7.0.190.0050.00517.01
7.0.180.0070.00717.05
7.0.170.0100.00316.93
7.0.160.0090.00616.99
7.0.150.0070.00716.98
7.0.140.0090.03719.47
7.0.130.0080.00817.14
7.0.120.0000.01216.95
7.0.110.0110.00616.84
7.0.100.0030.01016.95
7.0.90.0100.03318.31
7.0.80.0130.02618.49
7.0.70.0150.02718.42
7.0.60.0070.04718.46
7.0.50.0100.04018.70
7.0.40.0060.02317.57
7.0.30.0040.04617.49
7.0.20.0030.02717.53
7.0.10.0070.03917.49
7.0.00.0040.03617.46
5.6.400.0100.00715.67
5.6.390.0090.00615.68
5.6.380.0040.01416.03
5.6.370.0080.00416.04
5.6.360.0070.01115.95
5.6.350.0000.01016.06
5.6.340.0100.01016.01
5.6.330.0080.00615.90
5.6.320.0050.00915.79
5.6.310.0070.01115.88
5.6.300.0070.01115.82
5.6.290.0060.01015.71
5.6.280.0030.04318.58
5.6.270.0090.00916.09
5.6.260.0080.01115.74
5.6.250.0000.01815.75
5.6.240.0100.04518.25
5.6.230.0100.03218.08
5.6.220.0070.03718.17
5.6.210.0100.02018.17
5.6.200.0050.03118.42
5.6.190.0080.04518.58
5.6.180.0070.04518.41
5.6.170.0100.03818.40
5.6.160.0120.04518.33
5.6.150.0050.04318.38
5.6.140.0070.04218.45
5.6.130.0080.04918.44
5.6.120.0080.04718.34
5.6.110.0070.02718.49
5.6.100.0110.04318.44
5.6.90.0080.03318.53
5.6.80.0050.03618.08
5.6.70.0070.02317.99
5.6.60.0100.02518.13
5.6.50.0100.03917.95
5.6.40.0020.02718.07
5.6.30.0130.03618.09
5.6.20.0050.03118.10
5.6.10.0050.03318.05
5.6.00.0120.03918.00
5.5.380.0080.04118.04
5.5.370.0050.02618.08
5.5.360.0050.02918.00
5.5.350.0070.04318.02
5.5.340.0070.04318.34
5.5.330.0130.02018.34
5.5.320.0130.04518.36
5.5.310.0050.03018.29
5.5.300.0050.03018.46
5.5.290.0130.04018.38
5.5.280.0100.02318.26
5.5.270.0070.04318.33
5.5.260.0050.04918.31
5.5.250.0080.04318.21
5.5.240.0130.02817.97
5.5.230.0050.04417.98
5.5.220.0110.03817.90
5.5.210.0020.02417.99
5.5.200.0050.03217.95
5.5.190.0140.02017.94
5.5.180.0050.04018.01
5.5.170.0030.01215.86
5.5.160.0020.03417.98
5.5.150.0030.05118.04
5.5.140.0090.04017.96
5.5.130.0140.03818.05
5.5.120.0080.04217.95
5.5.110.0060.03618.03
5.5.100.0050.04017.90
5.5.90.0050.04717.85
5.5.80.0080.03717.78
5.5.70.0100.02217.90
5.5.60.0080.03717.87
5.5.50.0080.03517.82
5.5.40.0060.03317.84
5.5.30.0050.04717.85
5.5.20.0090.03017.90
5.5.10.0050.04417.83
5.5.00.0090.02717.84
5.4.450.0080.02616.03
5.4.440.0100.04115.97
5.4.430.0090.03515.96
5.4.420.0100.02516.07
5.4.410.0060.04515.92
5.4.400.0030.04715.79
5.4.390.0070.04015.87
5.4.380.0110.03915.92
5.4.370.0050.02415.91
5.4.360.0060.03015.77
5.4.350.0070.02515.78
5.4.340.0110.03615.93
5.4.330.0000.01212.70
5.4.320.0010.04315.89
5.4.310.0130.03715.88
5.4.300.0100.04015.96
5.4.290.0050.04315.89
5.4.280.0020.04515.87
5.4.270.0070.02915.86
5.4.260.0080.03315.96
5.4.250.0080.03715.91
5.4.240.0050.03915.79
5.4.230.0020.04415.96
5.4.220.0050.02315.79
5.4.210.0070.03915.77
5.4.200.0080.03515.94
5.4.190.0090.03415.91
5.4.180.0120.03515.79
5.4.170.0030.03015.77
5.4.160.0090.02515.86
5.4.150.0050.03415.90
5.4.140.0070.03814.56
5.4.130.0030.03814.63
5.4.120.0020.02314.57
5.4.110.0040.03114.57
5.4.100.0050.03714.57
5.4.90.0060.02914.67
5.4.80.0070.03714.59
5.4.70.0080.03014.62
5.4.60.0090.01714.59
5.4.50.0060.02714.57
5.4.40.0050.04414.55
5.4.30.0050.03814.53
5.4.20.0050.03814.58
5.4.10.0070.02314.55
5.4.00.0050.04014.22
5.3.290.0080.04113.88
5.3.280.0090.02013.77
5.3.270.0050.04013.85
5.3.260.0080.03913.87
5.3.250.0060.04113.84
5.3.240.0020.03413.79
5.3.230.0070.03813.85
5.3.220.0090.02613.82
5.3.210.0120.03513.84
5.3.200.0050.02713.73
5.3.190.0110.01713.85
5.3.180.0100.03813.87
5.3.170.0030.03013.83
5.3.160.0050.02313.80
5.3.150.0030.02413.82
5.3.140.0060.02513.87
5.3.130.0050.04313.82
5.3.120.0030.04313.93
5.3.110.0070.04213.84
5.3.100.0050.04013.49
5.3.90.0080.02013.66
5.3.80.0070.01713.49
5.3.70.0070.02013.44
5.3.60.0040.02413.46
5.3.50.0020.02413.41
5.3.40.0030.02213.49
5.3.30.0000.02713.36
5.3.20.0020.02513.31
5.3.10.0000.02313.26
5.3.00.0070.01713.17
5.2.170.0030.03011.09
5.2.160.0070.03011.19
5.2.150.0000.03311.17
5.2.140.0030.03011.19
5.2.130.0070.03011.16
5.2.120.0000.03011.07
5.2.110.0030.02711.25
5.2.100.0000.03011.17
5.2.90.0130.02311.23
5.2.80.0030.03011.02
5.2.70.0070.02711.16
5.2.60.0030.03311.02
5.2.50.0000.03010.98
5.2.40.0070.02311.04
5.2.30.0000.02710.98
5.2.20.0030.02311.12
5.2.10.0070.05310.84
5.2.00.0070.04710.68
5.1.60.0030.0239.86
5.1.50.0000.03010.07
5.1.40.0000.02710.00
5.1.30.0030.02710.50
5.1.20.0070.02310.44
5.1.10.0000.02710.16
5.1.00.0030.0209.94
5.0.50.0000.0238.66
5.0.40.0030.0178.56
5.0.30.0000.0338.30
5.0.20.0070.0138.23
5.0.10.0000.0208.30
5.0.00.0030.0278.20
4.4.90.0000.0177.09
4.4.80.0030.0137.09
4.4.70.0000.0177.09
4.4.60.0000.0177.09
4.4.50.0030.0177.09
4.4.40.0000.0277.09
4.4.30.0000.0177.09
4.4.20.0000.0177.09
4.4.10.0000.0277.09
4.4.00.0000.0337.09
4.3.110.0030.0207.09
4.3.100.0000.0177.09
4.3.90.0000.0137.09
4.3.80.0030.0207.09
4.3.70.0030.0137.09
4.3.60.0000.0137.09
4.3.50.0000.0137.09
4.3.40.0000.0237.09
4.3.30.0000.0177.09
4.3.20.0000.0177.09
4.3.10.0000.0237.09
4.3.00.0000.0207.09

preferences:
47.19 ms | 401 KiB | 5 Q