3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('json_encode')) { function json_encode($it) { $tmp = $it; if (!($assoc = is_object($it)) && !is_array($it)) { return _js_enc_value($it); } $i = 0; $it = (array)$it; var_dump($assoc); 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 = _js_enc_value($k); $data[] = $k . ':' . $v; } else { $data[] = $v; } } if ($assoc) { $bl = '{'; $br = '}'; } else { $bl = '['; $br = ']'; } return $bl . implode(',', $data) . $br; } function _js_enc_value($value) { switch (true) { case is_array($value): case is_object($value): return json_encode($value); case $value === null: case is_resource($value): return 'null'; case is_bool($value): return $value ? 'true' : 'false'; case is_string($value): return '"' . _js_uc_esc($value) . '"'; default: return $value; } } function _js_uc_esc($value) { $pattern = "@[\x08-\x10\x0c\x0d\\\\\"/]|([^\x08-\x10\x0c\x0d\x32-\x7f\\\\\"/])++@"; 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], "\x08\x09\x10\x0c\x0d\\\"/"); } } } /* $var = array( array( 'text', 1, 1.1, true, false, null, array(), new stdClass, ), array( '&\'/"' => "\r\n\t", ), array( '0' => 'hoge', '1' => 'foo', ), (object)array( '0' => 'hoge', '1' => 'foo', ), array( '0' => 'hoge', '2' => 'foo', ), (object)array( '0' => 'hoge', '2' => 'foo', ), ); var_dump(@json_encode($var)); */ var_dump(json_encode(array('1'=>'hoge')));

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.00618.13
8.3.50.0150.00622.06
8.3.40.0070.01418.69
8.3.30.0110.00319.04
8.3.20.0040.00420.34
8.3.10.0000.00723.48
8.3.00.0040.00420.75
8.2.180.0100.00716.63
8.2.170.0140.00322.96
8.2.160.0150.00622.30
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0060.00326.16
8.2.120.0070.00722.11
8.2.110.0090.00022.25
8.2.100.0090.00317.59
8.2.90.0080.00018.97
8.2.80.0030.00517.97
8.2.70.0090.00017.50
8.2.60.0080.00017.92
8.2.50.0100.00018.07
8.2.40.0040.00419.88
8.2.30.0000.00718.03
8.2.20.0000.00717.68
8.2.10.0040.00417.65
8.2.00.0000.00717.80
8.1.280.0070.00725.92
8.1.270.0080.00023.91
8.1.260.0060.00326.35
8.1.250.0090.00028.09
8.1.240.0030.00623.96
8.1.230.0070.00420.88
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0000.01017.25
8.1.190.0090.00017.66
8.1.180.0000.00818.10
8.1.170.0030.00518.63
8.1.160.0080.00022.00
8.1.150.0040.00418.70
8.1.140.0060.00317.46
8.1.130.0000.00717.79
8.1.120.0070.00017.46
8.1.110.0040.00417.45
8.1.100.0030.00617.48
8.1.90.0020.00517.43
8.1.80.0040.00417.46
8.1.70.0000.00717.46
8.1.60.0080.00017.62
8.1.50.0000.00817.51
8.1.40.0060.00317.39
8.1.30.0040.00417.66
8.1.20.0000.00817.64
8.1.10.0100.00017.48
8.1.00.0080.00017.27
8.0.300.0040.00418.77
8.0.290.0040.00417.28
8.0.280.0030.00318.45
8.0.270.0030.00517.31
8.0.260.0000.00816.74
8.0.250.0000.00616.98
8.0.240.0000.00816.82
8.0.230.0040.00416.95
8.0.220.0000.00816.91
8.0.210.0070.00016.92
8.0.200.0060.00316.86
8.0.190.0040.00416.87
8.0.180.0000.00916.96
8.0.170.0050.00316.92
8.0.160.0030.00616.91
8.0.150.0000.00716.84
8.0.140.0040.00416.81
8.0.130.0030.00313.26
8.0.120.0040.00416.87
8.0.110.0050.00216.82
8.0.100.0070.00016.78
8.0.90.0050.00216.71
8.0.80.0000.01516.84
8.0.70.0070.00016.74
8.0.60.0030.00516.90
8.0.50.0000.00816.85
8.0.30.0160.00716.84
8.0.20.0090.01417.40
8.0.10.0040.00416.94
8.0.00.0070.01216.70
7.4.330.0000.00615.00
7.4.320.0060.00016.57
7.4.300.0030.00316.50
7.4.290.0030.00316.53
7.4.280.0000.00816.41
7.4.270.0000.00716.62
7.4.260.0020.00516.47
7.4.250.0070.00016.55
7.4.240.0020.00616.46
7.4.230.0000.00816.41
7.4.220.0150.00016.63
7.4.210.0050.01216.43
7.4.200.0020.00516.45
7.4.190.0070.00016.57
7.4.160.0080.00816.33
7.4.150.0140.00717.40
7.4.140.0150.00617.86
7.4.130.0100.00816.36
7.4.120.0060.01316.54
7.4.110.0070.01716.55
7.4.100.0140.00716.49
7.4.90.0120.00616.35
7.4.80.0060.01416.32
7.4.70.0210.01416.36
7.4.60.0060.01216.49
7.4.50.0000.00816.52
7.4.40.0070.00722.77
7.4.30.0130.00316.53
7.4.10.0000.02014.79
7.4.00.0080.00814.63
7.3.330.0000.00613.27
7.3.320.0000.00613.18
7.3.310.0000.00716.06
7.3.300.0030.00316.10
7.3.290.0060.00916.23
7.3.280.0100.00716.26
7.3.270.0060.01217.40
7.3.260.0100.00716.21
7.3.250.0140.00316.42
7.3.240.0120.00416.22
7.3.230.0100.00716.45
7.3.210.0090.00816.31
7.3.200.0130.00619.39
7.3.190.0100.00716.42
7.3.180.0140.00716.53
7.3.170.0030.01316.27
7.3.160.0080.01216.16
7.3.130.0030.01614.68
7.3.120.0080.01014.91
7.3.110.0040.01414.65
7.3.100.0100.00514.65
7.3.90.0100.00514.71
7.3.80.0020.01114.86
7.3.70.0060.00914.85
7.3.60.0060.01014.73
7.3.50.0050.01014.68
7.3.40.0060.00814.74
7.3.30.0060.00614.61
7.3.20.0060.00616.52
7.3.10.0080.00716.56
7.3.00.0040.00816.49
7.2.330.0090.00916.63
7.2.320.0120.00616.48
7.2.310.0130.00316.41
7.2.300.0130.00416.33
7.2.290.0140.00316.22
7.2.260.0100.01015.15
7.2.250.0090.00915.05
7.2.240.0080.00814.90
7.2.230.0080.00814.75
7.2.220.0100.00614.82
7.2.210.0060.01114.89
7.2.200.0040.01114.87
7.2.190.0050.00914.88
7.2.180.0070.00714.83
7.2.170.0020.01314.84
7.2.160.0060.01114.98
7.2.150.0040.00916.68
7.2.140.0070.00716.66
7.2.130.0050.00816.77
7.2.120.0050.00716.77
7.2.110.0050.00816.75
7.2.100.0040.00916.75
7.2.90.0030.00716.80
7.2.80.0050.00916.85
7.2.70.0040.01016.73
7.2.60.0010.01316.71
7.2.50.0060.00516.76
7.2.40.0070.00716.72
7.2.30.0040.01016.74
7.2.20.0040.00716.59
7.2.10.0040.01016.59
7.2.00.0030.01017.29
7.1.330.0090.00415.75
7.1.320.0070.00615.59
7.1.310.0070.00715.70
7.1.300.0070.00615.57
7.1.290.0060.00615.37
7.1.280.0030.01215.48
7.1.270.0020.01015.67
7.1.260.0090.00715.71
7.1.250.0060.00815.58
7.1.240.0060.00615.58
7.1.230.0090.00615.75
7.1.220.0080.00615.71
7.1.210.0080.00015.48
7.1.200.0040.01115.39
7.1.190.0030.00915.53
7.1.180.0030.01015.74
7.1.170.0040.00715.64
7.1.160.0040.01115.59
7.1.150.0000.01015.50
7.1.140.0040.01415.55
7.1.130.0090.00615.74
7.1.120.0080.00415.71
7.1.110.0090.00615.73
7.1.100.0000.01016.93
7.1.90.0000.01615.59
7.1.80.0110.00415.67
7.1.70.0030.00916.33
7.1.60.0060.00917.45
7.1.50.0080.00716.24
7.1.40.0000.01115.57
7.1.30.0060.00315.64
7.1.20.0030.00715.82
7.1.10.0030.01015.76
7.1.00.0030.04218.92
7.0.330.0040.00415.45
7.0.320.0000.00915.22
7.0.310.0100.00015.29
7.0.300.0000.01215.47
7.0.290.0060.00615.32
7.0.280.0030.00615.43
7.0.270.0030.00715.14
7.0.260.0030.00715.20
7.0.250.0070.00715.27
7.0.240.0090.00315.22
7.0.230.0040.01215.26
7.0.220.0040.00415.41
7.0.210.0060.00615.32
7.0.200.0080.00615.94
7.0.190.0070.00315.13
7.0.180.0060.00915.46
7.0.170.0060.00615.10
7.0.160.0030.01015.01
7.0.150.0000.01015.30
7.0.140.0060.04018.60
7.0.130.0060.00315.23
7.0.120.0000.01115.51
7.0.110.0050.03317.71
7.0.100.0100.03617.70
7.0.90.0110.03817.77
7.0.80.0070.04517.72
7.0.70.0050.02917.59
7.0.60.0050.04017.77
7.0.50.0050.02417.80
7.0.40.0130.04016.75
7.0.30.0070.03016.79
7.0.20.0020.04616.80
7.0.10.0030.03716.68
7.0.00.0070.04916.72
5.6.400.0060.00914.04
5.6.390.0030.01314.55
5.6.380.0030.01014.14
5.6.370.0100.00314.57
5.6.360.0030.01314.51
5.6.350.0100.00314.20
5.6.340.0040.01213.91
5.6.330.0070.01014.45
5.6.320.0030.00913.80
5.6.310.0100.00614.38
5.6.300.0030.00914.04
5.6.290.0000.01814.20
5.6.280.0050.03817.76
5.6.270.0070.00414.32
5.6.260.0120.03317.53
5.6.250.0050.02717.47
5.6.240.0100.03317.32
5.6.230.0080.04117.53
5.6.220.0050.04417.33
5.6.210.0100.04217.54
5.6.200.0050.04617.51
5.6.190.0070.04117.73
5.6.180.0120.02717.75
5.6.170.0100.04717.78
5.6.160.0120.04417.73
5.6.150.0050.04617.74
5.6.140.0030.04917.80
5.6.130.0100.03817.71
5.6.120.0020.04717.68
5.6.110.0050.04817.56
5.6.100.0050.03217.71
5.6.90.0080.03617.64
5.6.80.0030.04617.29
5.6.70.0030.04417.28
5.6.60.0050.04417.29
5.6.50.0080.04317.40
5.6.40.0110.03217.19
5.6.30.0080.03817.31
5.6.20.0100.04217.47
5.6.10.0070.04517.24
5.6.00.0080.02517.30
5.5.380.0050.04717.30
5.5.370.0030.05017.49
5.5.360.0070.04517.32
5.5.350.0080.04517.26
5.5.340.0030.04617.31
5.5.330.0070.02717.63
5.5.320.0120.03617.48
5.5.310.0100.04517.64
5.5.300.0120.04217.47
5.5.290.0100.04017.51
5.5.280.0070.04517.42
5.5.270.0040.04117.48
5.5.260.0140.04017.59
5.5.250.0120.03817.32
5.5.240.0070.04717.01
5.5.230.0070.04317.21
5.5.220.0130.03817.19
5.5.210.0030.04717.23
5.5.200.0090.02617.07
5.5.190.0080.02817.21
5.5.180.0090.04417.27
5.5.170.0040.01814.21
5.5.160.0100.03817.21
5.5.150.0070.03217.36
5.5.140.0030.03717.06
5.5.130.0080.04117.21
5.5.120.0080.03517.23
5.5.110.0060.03817.23
5.5.100.0060.03917.17
5.5.90.0050.04317.31
5.5.80.0030.04317.23
5.5.70.0030.03217.04
5.5.60.0080.04217.05
5.5.50.0140.03716.93
5.5.40.0080.03817.07
5.5.30.0050.03117.21
5.5.20.0080.04117.03
5.5.10.0090.04017.05
5.5.00.0130.03817.02
5.4.450.0020.04115.84
5.4.440.0060.04315.78
5.4.430.0080.04215.77
5.4.420.0100.04015.79
5.4.410.0080.03715.66
5.4.400.0070.04215.61
5.4.390.0020.03115.57
5.4.380.0050.04115.50
5.4.370.0120.03715.53
5.4.360.0050.04315.60
5.4.350.0080.02315.51
5.4.340.0080.02515.59
5.4.330.0030.00612.04
5.4.320.0070.04215.52
5.4.310.0080.02915.53
5.4.300.0070.04215.49
5.4.290.0060.03815.64
5.4.280.0050.04015.51
5.4.270.0050.04215.68
5.4.260.0080.03515.61
5.4.250.0020.04315.61
5.4.240.0060.03915.52
5.4.230.0020.04515.52
5.4.220.0040.02715.69
5.4.210.0090.03715.69
5.4.200.0120.03515.51
5.4.190.0070.03815.49
5.4.180.0020.04415.67
5.4.170.0090.03515.69
5.4.160.0060.04115.56
5.4.150.0030.04315.49
5.4.140.0090.04014.24
5.4.130.0040.04114.30
5.4.120.0050.02714.32
5.4.110.0070.04014.33
5.4.100.0030.03614.33
5.4.90.0080.03814.28
5.4.80.0110.03414.34
5.4.70.0100.03814.25
5.4.60.0060.03814.28
5.4.50.0080.03514.30
5.4.40.0100.02214.19
5.4.30.0030.02514.24
5.4.20.0010.03814.29
5.4.10.0030.02114.21
5.4.00.0050.02813.89
5.3.290.0080.02913.49
5.3.280.0080.02313.32
5.3.270.0130.03513.40
5.3.260.0070.04113.32
5.3.250.0050.03713.40
5.3.240.0080.03613.34
5.3.230.0090.03713.31
5.3.220.0070.03713.31
5.3.210.0070.03813.25
5.3.200.0060.03813.32
5.3.190.0090.02513.33
5.3.180.0070.04013.31
5.3.170.0020.03113.24
5.3.160.0070.03813.39
5.3.150.0040.04013.38
5.3.140.0060.03513.29
5.3.130.0030.03313.30
5.3.120.0080.02213.37
5.3.110.0080.02313.30
5.3.100.0020.04013.04
5.3.90.0040.02013.04
5.3.80.0040.03113.05
5.3.70.0080.02113.04
5.3.60.0000.02213.10
5.3.50.0030.02213.05
5.3.40.0040.02113.04
5.3.30.0030.02512.99
5.3.20.0020.02312.90
5.3.10.0020.02212.87
5.3.00.0060.03712.86
5.2.170.0070.02312.72
5.2.160.0000.03012.72
5.2.150.0030.02712.72
5.2.140.0000.03012.72
5.2.130.0030.02712.72
5.2.120.0000.03012.72
5.2.110.0030.03012.72
5.2.100.0000.03012.72
5.2.90.0030.02712.72
5.2.80.0030.02712.72
5.2.70.0030.03312.72
5.2.60.0030.05712.72
5.2.50.0030.03712.72
5.2.40.0000.03012.72
5.2.30.0030.03712.72
5.2.20.0030.05012.72
5.2.10.0070.02312.72
5.2.00.0030.06312.72
5.1.60.0030.02012.72
5.1.50.0030.02012.72
5.1.40.0030.02312.72
5.1.30.0030.04012.72
5.1.20.0000.02712.72
5.1.10.0000.02712.72
5.1.00.0000.03312.72
5.0.50.0000.04012.72
5.0.40.0000.02312.72
5.0.30.0000.03312.72
5.0.20.0070.02012.72
5.0.10.0000.02012.72
5.0.00.0030.03012.72
4.4.90.0030.01312.72
4.4.80.0000.03012.72
4.4.70.0030.03012.72
4.4.60.0000.03012.72
4.4.50.0030.03312.72
4.4.40.0070.04712.72
4.4.30.0000.02012.72
4.4.20.0000.01712.72
4.4.10.0000.01712.72
4.4.00.0000.02712.72
4.3.110.0000.02712.72
4.3.100.0000.01312.72
4.3.90.0000.01712.72
4.3.80.0000.04712.72
4.3.70.0000.02312.72
4.3.60.0000.01712.72
4.3.50.0000.02712.72
4.3.40.0000.02312.72
4.3.30.0000.01312.72
4.3.20.0000.01712.72
4.3.10.0030.02012.72
4.3.00.0000.02012.72

preferences:
52.03 ms | 401 KiB | 5 Q