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) { $k = '"'. addcslashes($k, '"\\') . '"'; $v = _js_enc_value($v); $data[] = $assoc ? $k . ':' . $v : $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.0090.00616.62
8.3.50.0130.00722.00
8.3.40.0070.00718.67
8.3.30.0090.00618.86
8.3.20.0120.00320.29
8.3.10.0030.00523.66
8.3.00.0070.01019.36
8.2.180.0060.00916.63
8.2.170.0180.00422.96
8.2.160.0050.00820.35
8.2.150.0070.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00022.32
8.2.110.0030.00722.24
8.2.100.0040.00717.84
8.2.90.0040.00419.26
8.2.80.0030.00617.97
8.2.70.0080.00017.63
8.2.60.0030.00518.04
8.2.50.0060.00318.07
8.2.40.0030.00518.30
8.2.30.0050.00318.24
8.2.20.0040.00417.71
8.2.10.0060.00319.92
8.2.00.0060.00317.77
8.1.280.0190.00025.92
8.1.270.0070.00323.87
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0030.00623.81
8.1.230.0030.01019.12
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0030.00717.23
8.1.190.0040.00417.41
8.1.180.0000.00918.10
8.1.170.0130.00018.66
8.1.160.0000.00822.04
8.1.150.0040.00418.68
8.1.140.0030.00617.40
8.1.130.0030.00317.87
8.1.120.0060.00317.52
8.1.110.0000.00717.49
8.1.100.0000.00817.33
8.1.90.0080.00017.52
8.1.80.0000.00717.44
8.1.70.0000.00817.42
8.1.60.0050.00317.64
8.1.50.0050.00317.54
8.1.40.0030.00517.61
8.1.30.0030.00617.66
8.1.20.0000.00717.61
8.1.10.0050.00317.62
8.1.00.0030.00517.56
8.0.300.0040.00418.77
8.0.290.0000.00817.30
8.0.280.0000.00718.56
8.0.270.0030.00317.43
8.0.260.0040.00416.93
8.0.250.0030.00316.97
8.0.240.0030.00617.06
8.0.230.0030.00517.10
8.0.220.0040.00417.02
8.0.210.0030.00316.89
8.0.200.0000.00717.08
8.0.190.0000.00817.03
8.0.180.0040.00416.98
8.0.170.0070.00017.02
8.0.160.0000.00816.99
8.0.150.0000.00716.96
8.0.140.0000.00716.95
8.0.130.0050.00013.39
8.0.120.0030.00516.90
8.0.110.0070.00016.91
8.0.100.0070.00016.96
8.0.90.0050.00216.90
8.0.80.0190.00017.06
8.0.70.0040.00416.94
8.0.60.0080.00016.95
8.0.50.0030.00516.98
8.0.30.0140.00617.10
8.0.20.0060.01317.45
8.0.10.0000.00816.84
8.0.00.0100.00816.86
7.4.330.0000.00615.10
7.4.320.0030.00316.54
7.4.300.0030.00316.63
7.4.290.0030.00316.55
7.4.280.0000.00816.66
7.4.270.0000.00716.46
7.4.260.0030.00316.61
7.4.250.0000.00816.52
7.4.240.0030.00316.59
7.4.230.0000.00716.72
7.4.220.0090.01216.58
7.4.210.0090.00816.64
7.4.200.0040.00416.58
7.4.190.0000.00716.45
7.4.160.0060.00916.60
7.4.150.0040.01417.40
7.4.140.0070.01017.86
7.4.130.0050.01116.54
7.4.120.0100.00816.58
7.4.110.0100.00716.66
7.4.100.0130.00716.51
7.4.90.0080.00816.54
7.4.80.0040.01419.39
7.4.70.0070.01116.55
7.4.60.0070.01016.43
7.4.50.0040.00416.68
7.4.40.0090.00522.77
7.4.30.0100.00716.52
7.4.10.0070.01015.09
7.4.00.0060.01015.13
7.3.330.0030.00313.37
7.3.320.0000.00713.36
7.3.310.0000.00716.38
7.3.300.0000.00716.21
7.3.290.0090.00616.34
7.3.280.0110.00716.35
7.3.270.0110.00617.40
7.3.260.0120.01216.48
7.3.250.0110.01316.29
7.3.240.0150.00716.52
7.3.230.0030.01316.39
7.3.210.0030.01316.41
7.3.200.0140.01019.39
7.3.190.0150.00616.46
7.3.180.0130.00316.38
7.3.170.0080.00816.49
7.3.160.0070.01016.48
7.3.130.0160.00014.97
7.3.120.0060.01114.92
7.3.110.0000.01514.80
7.3.100.0110.00314.93
7.3.90.0060.00314.73
7.3.80.0090.00314.91
7.3.70.0070.00714.82
7.3.60.0040.01214.93
7.3.50.0030.00614.69
7.3.40.0070.00714.80
7.3.30.0030.01014.85
7.3.20.0030.01416.68
7.3.10.0090.00916.44
7.3.00.0000.01416.46
7.2.330.0030.01316.49
7.2.320.0070.01516.65
7.2.310.0160.00616.73
7.2.300.0100.00716.55
7.2.290.0140.00716.48
7.2.260.0050.01314.98
7.2.250.0090.00915.20
7.2.240.0110.00614.73
7.2.230.0100.00314.91
7.2.220.0070.01114.56
7.2.210.0100.00315.05
7.2.200.0040.00815.14
7.2.190.0060.00614.84
7.2.180.0060.00615.14
7.2.170.0070.00715.14
7.2.160.0000.01715.06
7.2.150.0110.00416.49
7.2.140.0060.00916.82
7.2.130.0130.00016.63
7.2.120.0080.01116.94
7.2.110.0110.00316.79
7.2.100.0000.01216.75
7.2.90.0100.00716.78
7.2.80.0030.01416.57
7.2.70.0000.01117.00
7.2.60.0130.00316.83
7.2.50.0100.00316.79
7.2.40.0090.00616.98
7.2.30.0000.01316.79
7.2.20.0090.00616.87
7.2.10.0030.01216.51
7.2.00.0110.00317.98
7.1.330.0040.01115.87
7.1.320.0050.00515.90
7.1.310.0070.00415.57
7.1.300.0030.00915.57
7.1.290.0080.00515.49
7.1.280.0070.00415.78
7.1.270.0110.00415.73
7.1.260.0100.00615.72
7.1.250.0060.00915.70
7.1.240.0040.01415.54
7.1.230.0060.00315.40
7.1.220.0030.01015.71
7.1.210.0000.01515.88
7.1.200.0130.00815.58
7.1.190.0060.00615.47
7.1.180.0110.00415.78
7.1.170.0040.00715.91
7.1.160.0090.00915.64
7.1.150.0030.00915.74
7.1.140.0100.00315.95
7.1.130.0090.00615.63
7.1.120.0100.00315.59
7.1.110.0030.01015.90
7.1.100.0030.00917.05
7.1.90.0000.01415.75
7.1.80.0070.00315.82
7.1.70.0030.00816.31
7.1.60.0080.00817.55
7.1.50.0070.01216.16
7.1.40.0030.01315.69
7.1.30.0060.00915.71
7.1.20.0030.00915.41
7.1.10.0000.01615.60
7.1.00.0030.04418.89
7.0.330.0060.01015.21
7.0.320.0050.00515.22
7.0.310.0030.00615.36
7.0.300.0070.00715.39
7.0.290.0080.00815.26
7.0.280.0040.00815.35
7.0.270.0030.01215.33
7.0.260.0090.00315.07
7.0.250.0030.01015.31
7.0.240.0040.00815.39
7.0.230.0060.00915.12
7.0.220.0030.01015.50
7.0.210.0040.00415.38
7.0.200.0040.00516.05
7.0.190.0150.00015.35
7.0.180.0030.00915.24
7.0.170.0110.00315.38
7.0.160.0030.00715.62
7.0.150.0070.00715.29
7.0.140.0040.04018.64
7.0.130.0060.00915.54
7.0.120.0100.00315.14
7.0.110.0090.00615.46
7.0.100.0060.00915.20
7.0.90.0030.04317.69
7.0.80.0030.02817.55
7.0.70.0360.04317.58
7.0.60.0320.04217.51
7.0.50.0290.03017.87
7.0.40.0070.04616.69
7.0.30.0050.04016.65
7.0.20.0070.03016.77
7.0.10.0080.04316.56
7.0.00.0080.03716.81
5.6.400.0030.01214.41
5.6.390.0030.01214.54
5.6.380.0030.01214.12
5.6.370.0030.00614.28
5.6.360.0060.00914.27
5.6.350.0070.00714.43
5.6.340.0040.01114.52
5.6.330.0060.00914.59
5.6.320.0060.00614.61
5.6.310.0000.01314.68
5.6.300.0100.00314.48
5.6.290.0110.00014.40
5.6.280.0050.03817.59
5.6.270.0000.00914.29
5.6.260.0030.01014.43
5.6.250.0100.00714.52
5.6.240.0030.03817.48
5.6.230.0030.03717.49
5.6.220.0080.04117.54
5.6.210.0030.04417.40
5.6.200.0090.04317.62
5.6.190.0070.04417.61
5.6.180.0020.02917.63
5.6.170.0080.04617.71
5.6.160.0050.03717.70
5.6.150.0160.03917.82
5.6.140.0140.03917.76
5.6.130.0090.03217.61
5.6.120.0040.04417.58
5.6.110.0050.05017.69
5.6.100.0090.04217.72
5.6.90.0100.04017.65
5.6.80.0080.02817.42
5.6.70.0080.03917.32
5.6.60.0050.04317.21
5.6.50.0130.02617.33
5.6.40.0050.04317.53
5.6.30.0030.03917.27
5.6.20.0090.02517.42
5.6.10.0090.03317.23
5.6.00.0080.04517.45
5.5.380.0100.03717.16
5.5.370.0030.04517.34
5.5.360.0060.04117.26
5.5.350.0080.02817.46
5.5.340.0030.04317.37
5.5.330.0050.04417.73
5.5.320.0030.03317.49
5.5.310.0030.04717.59
5.5.300.0030.04517.36
5.5.290.0030.03117.42
5.5.280.0100.04217.68
5.5.270.0100.04517.64
5.5.260.0070.03517.61
5.5.250.0030.03817.46
5.5.240.0070.04517.14
5.5.230.0110.03717.21
5.5.220.0070.04217.26
5.5.210.0070.02817.20
5.5.200.0090.03817.16
5.5.190.0030.04717.07
5.5.180.0050.04317.21
5.5.170.0070.00714.39
5.5.160.0070.04617.21
5.5.150.0020.03017.09
5.5.140.0050.04217.15
5.5.130.0050.04217.21
5.5.120.0080.03717.12
5.5.110.0070.04417.17
5.5.100.0070.04117.14
5.5.90.0050.04817.26
5.5.80.0070.04217.23
5.5.70.0050.03517.17
5.5.60.0000.04417.17
5.5.50.0070.04017.08
5.5.40.0080.03516.96
5.5.30.0120.03617.23
5.5.20.0070.02717.28
5.5.10.0100.02816.93
5.5.00.0050.03017.19
5.4.450.0090.03815.94
5.4.440.0050.02816.03
5.4.430.0100.04116.08
5.4.420.0070.03716.10
5.4.410.0100.03815.86
5.4.400.0050.03815.88
5.4.390.0080.03515.88
5.4.380.0030.04115.89
5.4.370.0070.02315.90
5.4.360.0080.04115.79
5.4.350.0100.03215.76
5.4.340.0050.04115.80
5.4.330.0040.00412.64
5.4.320.0030.04015.89
5.4.310.0040.02715.91
5.4.300.0070.03515.84
5.4.290.0070.02515.83
5.4.280.0030.03915.77
5.4.270.0030.04015.77
5.4.260.0030.03215.88
5.4.250.0030.04315.90
5.4.240.0040.02715.87
5.4.230.0070.03815.93
5.4.220.0100.04115.79
5.4.210.0060.03615.83
5.4.200.0030.04515.77
5.4.190.0040.03415.79
5.4.180.0020.04215.75
5.4.170.0070.03915.88
5.4.160.0050.02515.90
5.4.150.0030.03815.79
5.4.140.0030.03814.57
5.4.130.0070.03614.53
5.4.120.0050.03714.49
5.4.110.0060.03614.54
5.4.100.0080.04014.56
5.4.90.0050.04314.59
5.4.80.0030.02214.50
5.4.70.0030.04014.50
5.4.60.0020.03014.51
5.4.50.0090.03514.50
5.4.40.0050.03814.53
5.4.30.0120.01714.54
5.4.20.0050.03814.53
5.4.10.0070.03714.54
5.4.00.0030.03014.25
5.3.290.0030.03013.63
5.3.280.0080.03813.62
5.3.270.0090.03813.70
5.3.260.0070.04013.61
5.3.250.0130.02813.67
5.3.240.0030.03613.60
5.3.230.0040.02513.66
5.3.220.0070.02813.61
5.3.210.0030.03713.60
5.3.200.0050.03813.69
5.3.190.0050.04213.68
5.3.180.0060.02713.61
5.3.170.0110.02113.62
5.3.160.0040.02413.66
5.3.150.0060.04013.68
5.3.140.0020.04013.64
5.3.130.0030.04013.63
5.3.120.0030.02713.61
5.3.110.0010.03613.60
5.3.100.0020.03213.32
5.3.90.0050.03513.39
5.3.80.0070.02513.35
5.3.70.0020.02613.39
5.3.60.0090.03213.37
5.3.50.0020.04213.38
5.3.40.0060.02713.25
5.3.30.0100.02313.36
5.3.20.0080.03813.13
5.3.10.0050.03513.12
5.3.00.0080.03713.18
5.2.170.0030.06711.28
5.2.160.0100.05711.03
5.2.150.0030.03711.05
5.2.140.0030.03011.26
5.2.130.0070.03311.04
5.2.120.0030.06311.06
5.2.110.0100.06011.25
5.2.100.0070.06011.19
5.2.90.0070.06011.06
5.2.80.0100.05311.04
5.2.70.0030.06711.13
5.2.60.0100.06011.11
5.2.50.0070.05711.15
5.2.40.0070.03711.02
5.2.30.0030.03311.12
5.2.20.0130.05311.01
5.2.10.0100.05011.03
5.2.00.0000.06310.86
5.1.60.0030.05310.09
5.1.50.0070.03010.10
5.1.40.0030.05710.09
5.1.30.0030.05710.38
5.1.20.0070.02710.39
5.1.10.0100.05310.17
5.1.00.0070.05310.18
5.0.50.0030.0508.59
5.0.40.0170.0308.55
5.0.30.0070.0438.38
5.0.20.0000.0438.31
5.0.10.0000.0278.22
5.0.00.0000.0408.30
4.4.90.0030.0337.61
4.4.80.0030.0207.61
4.4.70.0070.0237.61
4.4.60.0030.0377.61
4.4.50.0000.0377.61
4.4.40.0000.0407.61
4.4.30.0030.0207.61
4.4.20.0000.0407.61
4.4.10.0000.0337.61
4.4.00.0030.0537.61
4.3.110.0000.0337.61
4.3.100.0000.0407.61
4.3.90.0000.0337.61
4.3.80.0100.0237.61
4.3.70.0030.0277.61
4.3.60.0070.0307.61
4.3.50.0070.0337.61
4.3.40.0070.0377.61
4.3.30.0030.0307.61
4.3.20.0000.0237.61
4.3.10.0070.0307.61
4.3.00.0030.0377.61

preferences:
54.77 ms | 401 KiB | 5 Q