3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('json_encode')) { function json_encode($it) { if (!($is_arr = is_array($it)) && !is_object($it)) { return _js_enc_value($it); } $assoc = false; $i = 0; foreach ($it as $k => $v) { if ($k !== $i) { $assoc = true; break; } $i++; } if (!$is_arr) { $assoc = true; } $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): return 'null'; case is_string($value): return '"' . _js_uc_esc($value) . '"'; default: return $value; } } 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'; } } } $var = array( 0 => array('text', 1, 1.1, true, false, null, array(), new stdClass, @fopen('php://stdin', 'r')), 2 => array('a' => 'hoge', 'b' => 'foo'), ); var_dump(@json_encode($var));

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.0070.01418.56
8.3.50.0110.00521.99
8.3.40.0090.00918.45
8.3.30.0090.00618.89
8.3.20.0030.00518.64
8.3.10.0040.00421.09
8.3.00.0040.00423.70
8.2.180.0120.00316.60
8.2.170.0120.00322.96
8.2.160.0100.00320.53
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0090.00026.16
8.2.120.0080.00019.36
8.2.110.0030.00720.47
8.2.100.0040.00717.78
8.2.90.0000.00819.22
8.2.80.0040.00417.97
8.2.70.0070.00317.63
8.2.60.0060.00317.93
8.2.50.0050.00518.07
8.2.40.0000.00818.16
8.2.30.0060.00319.47
8.2.20.0070.00017.82
8.2.10.0080.00017.74
8.2.00.0050.00317.73
8.1.280.0140.00325.92
8.1.270.0050.00322.19
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0120.00622.52
8.1.230.0090.00320.98
8.1.220.0040.00418.77
8.1.210.0030.00518.84
8.1.200.0060.00317.35
8.1.190.0080.00017.41
8.1.180.0050.00318.10
8.1.170.0000.00818.58
8.1.160.0080.00018.84
8.1.150.0070.00018.55
8.1.140.0050.00217.37
8.1.130.0000.00717.79
8.1.120.0000.00817.39
8.1.110.0000.00817.51
8.1.100.0000.00817.50
8.1.90.0040.00417.41
8.1.80.0000.00817.49
8.1.70.0030.00517.44
8.1.60.0040.00417.63
8.1.50.0030.00617.48
8.1.40.0040.00417.62
8.1.30.0000.00717.57
8.1.20.0050.00317.55
8.1.10.0040.00417.67
8.1.00.0070.00317.57
8.0.300.0040.00420.18
8.0.290.0040.00417.43
8.0.280.0030.00318.62
8.0.270.0030.00317.37
8.0.260.0000.00716.89
8.0.250.0030.00517.08
8.0.240.0050.00216.94
8.0.230.0050.00317.04
8.0.220.0000.00917.01
8.0.210.0030.00317.02
8.0.200.0040.00416.95
8.0.190.0040.00416.96
8.0.180.0060.00316.93
8.0.170.0000.00817.02
8.0.160.0050.00217.01
8.0.150.0050.00216.83
8.0.140.0040.00716.97
8.0.130.0000.00513.38
8.0.120.0000.00816.86
8.0.110.0040.00416.96
8.0.100.0020.00517.03
8.0.90.0000.00716.96
8.0.80.0030.01417.00
8.0.70.0000.00817.05
8.0.60.0040.00417.00
8.0.50.0000.00816.87
8.0.30.0080.01117.23
8.0.20.0060.01217.40
8.0.10.0040.00416.92
8.0.00.0100.00816.69
7.4.330.0020.00216.85
7.4.320.0000.00616.47
7.4.300.0040.00416.53
7.4.290.0030.00316.45
7.4.280.0000.00716.68
7.4.270.0000.00716.68
7.4.260.0030.00313.31
7.4.250.0060.00316.62
7.4.240.0030.00316.70
7.4.230.0040.00416.59
7.4.220.0170.00916.53
7.4.210.0070.01116.71
7.4.200.0040.00416.59
7.4.190.0070.00016.72
7.4.160.0150.00816.42
7.4.150.0120.00617.40
7.4.140.0150.01017.86
7.4.130.0140.00316.46
7.4.120.0110.00616.62
7.4.110.0120.01016.58
7.4.100.0090.01216.59
7.4.90.0120.00616.52
7.4.80.0090.00919.39
7.4.70.0120.00316.36
7.4.60.0100.00716.34
7.4.50.0000.00916.55
7.4.40.0030.01322.77
7.4.30.0100.01016.59
7.4.00.0090.00615.20
7.3.330.0060.00013.18
7.3.320.0030.00313.36
7.3.310.0080.00016.35
7.3.300.0040.00416.31
7.3.290.0110.00316.41
7.3.280.0060.01316.32
7.3.270.0140.00317.40
7.3.260.0100.00818.24
7.3.250.0090.00816.44
7.3.240.0140.00316.54
7.3.230.0070.01016.39
7.3.210.0170.00016.39
7.3.200.0120.00619.39
7.3.190.0130.00316.53
7.3.180.0090.00716.36
7.3.170.0080.00716.34
7.3.160.0070.01016.34
7.3.120.0050.01014.59
7.3.110.0000.01914.71
7.3.100.0060.01214.51
7.3.90.0030.01214.51
7.3.80.0090.00614.75
7.3.70.0070.00714.96
7.3.60.0030.01214.72
7.3.50.0030.00614.73
7.3.40.0070.00714.57
7.3.30.0100.00314.95
7.3.20.0100.00316.43
7.3.10.0080.00516.53
7.3.00.0070.00516.38
7.2.330.0030.01316.47
7.2.320.0150.00316.63
7.2.310.0130.01016.51
7.2.300.0070.01016.40
7.2.290.0030.01316.42
7.2.250.0000.01615.00
7.2.240.0130.00615.24
7.2.230.0090.00614.97
7.2.220.0070.00715.07
7.2.210.0090.00615.10
7.2.200.0040.01114.85
7.2.190.0080.00815.24
7.2.180.0040.00714.77
7.2.170.0030.01214.82
7.2.160.0000.00914.56
7.2.150.0130.00316.98
7.2.140.0070.01016.55
7.2.130.0120.00516.66
7.2.120.0050.01216.77
7.2.110.0080.00716.78
7.2.100.0000.01216.80
7.2.90.0090.00416.65
7.2.80.0050.01116.84
7.2.70.0060.00816.80
7.2.60.0100.00816.74
7.2.50.0060.00916.75
7.2.40.0070.00516.81
7.2.30.0070.01016.72
7.2.20.0020.01516.89
7.2.10.0130.00716.90
7.2.00.0100.00617.49
7.1.330.0070.01015.72
7.1.320.0000.01515.57
7.1.310.0000.00915.62
7.1.300.0060.00315.82
7.1.290.0040.01115.73
7.1.280.0070.00315.91
7.1.270.0040.01115.31
7.1.260.0070.00415.80
7.1.250.0060.01115.61
7.1.240.0070.00715.81
7.1.230.0060.00315.52
7.1.220.0000.01415.60
7.1.210.0030.01015.76
7.1.200.0000.01415.41
7.1.190.0070.00715.85
7.1.180.0060.00915.57
7.1.170.0000.01715.80
7.1.160.0000.01415.73
7.1.150.0000.00915.98
7.1.140.0040.01115.82
7.1.130.0000.01415.62
7.1.120.0120.00315.62
7.1.110.0100.00715.58
7.1.100.0040.00916.98
7.1.90.0060.00915.82
7.1.80.0000.01515.78
7.1.70.0060.00716.23
7.1.60.0040.01016.46
7.1.50.0090.00816.26
7.1.40.0030.00915.93
7.1.30.0030.01015.53
7.1.20.0070.00415.80
7.1.10.0090.00615.53
7.1.00.0030.03819.16
7.0.330.0110.00315.27
7.0.320.0070.00415.34
7.0.310.0040.00415.40
7.0.300.0100.00715.23
7.0.290.0030.01315.52
7.0.280.0090.00015.20
7.0.270.0040.00415.52
7.0.260.0070.01115.31
7.0.250.0000.01515.36
7.0.240.0070.00715.54
7.0.230.0040.01115.32
7.0.220.0060.00915.25
7.0.210.0040.01115.28
7.0.200.0080.00815.88
7.0.190.0030.01215.34
7.0.180.0030.01015.23
7.0.170.0060.00615.24
7.0.160.0040.01115.36
7.0.150.0030.00815.42
7.0.140.0080.03918.82
7.0.130.0070.00415.44
7.0.120.0040.00815.55
7.0.110.0070.00715.41
7.0.100.0050.00515.44
7.0.90.0180.03217.71
7.0.80.0380.04517.61
7.0.70.0380.04017.58
7.0.60.0300.02717.68
7.0.50.0330.04417.68
7.0.40.0080.04416.71
7.0.30.0090.03916.71
7.0.20.0070.03816.67
7.0.10.0090.04416.71
7.0.00.0020.04116.74
5.6.400.0030.01314.09
5.6.390.0040.01114.03
5.6.380.0030.01214.49
5.6.370.0040.01114.52
5.6.360.0000.01414.59
5.6.350.0070.01114.31
5.6.340.0070.01014.20
5.6.330.0040.00814.19
5.6.320.0060.00614.32
5.6.310.0100.00614.63
5.6.300.0030.00614.17
5.6.290.0000.01214.49
5.6.280.0030.04217.69
5.6.270.0070.01114.34
5.6.260.0070.00714.01
5.6.250.0030.01314.59
5.6.240.0120.04117.47
5.6.230.0090.02817.53
5.6.220.0120.03917.50
5.6.210.0070.02517.51
5.6.200.0100.03417.71
5.6.190.0140.03517.60
5.6.180.0050.03017.66
5.6.170.0140.03417.70
5.6.160.0120.03717.77
5.6.150.0110.03817.66
5.6.140.0070.04117.80
5.6.130.0050.02717.74
5.6.120.0080.04217.62
5.6.110.0090.04617.76
5.6.100.0140.03517.67
5.6.90.0050.03017.70
5.6.80.0030.03617.41
5.6.70.0080.03417.38
5.6.60.0030.04217.23
5.6.50.0120.04217.20
5.6.40.0080.02917.17
5.6.30.0060.03117.35
5.6.20.0120.04017.38
5.6.10.0100.04017.41
5.6.00.0080.03317.40
5.5.380.0050.02717.38
5.5.370.0030.02717.44
5.5.360.0070.02217.51
5.5.350.0020.02817.27
5.5.340.0090.03217.58
5.5.330.0070.04217.55
5.5.320.0050.03517.60
5.5.310.0070.04517.60
5.5.300.0080.03817.50
5.5.290.0060.03617.62
5.5.280.0120.04317.62
5.5.270.0020.03017.48
5.5.260.0050.02717.60
5.5.250.0090.04417.34
5.5.240.0070.03817.30
5.5.230.0070.04217.29
5.5.220.0100.04117.37
5.5.210.0050.04917.09
5.5.200.0110.04017.22
5.5.190.0050.02817.20
5.5.180.0100.02317.12
5.5.170.0060.01014.02
5.5.160.0150.04017.17
5.5.150.0100.03717.08
5.5.140.0060.03817.25
5.5.130.0110.03817.20
5.5.120.0070.02717.06
5.5.110.0030.03217.29
5.5.100.0070.04017.02
5.5.90.0050.02517.20
5.5.80.0070.04117.13
5.5.70.0000.04417.11
5.5.60.0130.02117.07
5.5.50.0080.03917.07
5.5.40.0160.01517.17
5.5.30.0040.02717.30
5.5.20.0040.03917.23
5.5.10.0030.03217.07
5.5.00.0050.04517.19
5.4.450.0050.03815.69
5.4.440.0020.04715.83
5.4.430.0020.04515.64
5.4.420.0100.02015.78
5.4.410.0050.04315.78
5.4.400.0050.02415.48
5.4.390.0020.04815.68
5.4.380.0060.03515.64
5.4.370.0070.03515.51
5.4.360.0130.03615.48
5.4.350.0070.04015.48
5.4.340.0020.03915.57
5.4.330.0040.00812.11
5.4.320.0080.02915.62
5.4.310.0070.03115.62
5.4.300.0050.03615.65
5.4.290.0030.04415.58
5.4.280.0130.03315.60
5.4.270.0130.03615.57
5.4.260.0070.04015.67
5.4.250.0080.02615.47
5.4.240.0070.02615.67
5.4.230.0060.02615.57
5.4.220.0050.03015.61
5.4.210.0110.03615.61
5.4.200.0070.02015.50
5.4.190.0070.02715.65
5.4.180.0070.04115.65
5.4.170.0100.01815.59
5.4.160.0080.03515.50
5.4.150.0080.03515.56
5.4.140.0050.02414.22
5.4.130.0040.03214.15
5.4.120.0070.03714.15
5.4.110.0030.02214.33
5.4.100.0050.03714.29
5.4.90.0050.03814.32
5.4.80.0020.02714.28
5.4.70.0070.03014.32
5.4.60.0110.03314.21
5.4.50.0100.03514.25
5.4.40.0080.03014.30
5.4.30.0090.04314.25
5.4.20.0150.01514.20
5.4.10.0050.04014.18
5.4.00.0020.04413.95
5.3.290.0020.04713.39
5.3.280.0030.02513.36
5.3.270.0070.02113.41
5.3.260.0130.02113.38
5.3.250.0050.03413.37
5.3.240.0050.03613.33
5.3.230.0050.04013.42
5.3.220.0030.04313.40
5.3.210.0100.03313.36
5.3.200.0070.03013.36
5.3.190.0050.04213.31
5.3.180.0040.03413.35
5.3.170.0030.04013.31
5.3.160.0080.02313.35
5.3.150.0050.03913.39
5.3.140.0010.04813.37
5.3.130.0080.03713.33
5.3.120.0070.04013.40
5.3.110.0050.03213.41
5.3.100.0080.03913.07
5.3.90.0040.03713.15
5.3.80.0020.03613.04
5.3.70.0000.03913.12
5.3.60.0020.03713.02
5.3.50.0030.03813.07
5.3.40.0080.02312.98
5.3.30.0100.03312.98
5.3.20.0070.02612.91
5.3.10.0030.04212.84
5.3.00.0050.02312.84
5.2.170.0130.02311.26
5.2.160.0070.02711.19
5.2.150.0070.02711.06
5.2.140.0130.05311.07
5.2.130.0000.07011.12
5.2.120.0070.04311.18
5.2.110.0000.06711.19
5.2.100.0070.06011.13
5.2.90.0070.04311.18
5.2.80.0070.04011.14
5.2.70.0030.06011.24
5.2.60.0100.03711.16
5.2.50.0100.05710.99
5.2.40.0030.06311.14
5.2.30.0070.04710.89
5.2.20.0070.05311.05
5.2.10.0000.03711.03
5.2.00.0070.06010.84
5.1.60.0030.04710.03
5.1.50.0000.05710.02
5.1.40.0070.0509.99
5.1.30.0000.06010.43
5.1.20.0070.05010.44
5.1.10.0070.04710.12
5.1.00.0100.05010.19
5.0.50.0030.0478.59
5.0.40.0000.0308.55
5.0.30.0030.0608.34
5.0.20.0000.0278.34
5.0.10.0070.0408.23
5.0.00.0030.0638.23
4.4.90.0000.0377.88
4.4.80.0100.0307.88
4.4.70.0070.0307.88
4.4.60.0000.0377.88
4.4.50.0030.0337.88
4.4.40.0070.0477.88
4.4.30.0000.0407.88
4.4.20.0070.0307.88
4.4.10.0030.0377.88
4.4.00.0000.0537.88
4.3.110.0030.0337.88
4.3.100.0100.0137.88
4.3.90.0030.0237.88
4.3.80.0000.0577.88
4.3.70.0000.0377.88
4.3.60.0000.0337.88
4.3.50.0030.0207.88
4.3.40.0030.0237.88
4.3.30.0000.0177.88
4.3.20.0030.0137.88
4.3.10.0030.0237.88
4.3.00.0000.0377.88

preferences:
103.5 ms | 401 KiB | 5 Q