3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!function_exists('json_encode')) { function json_encode($it) { if (!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++; } $data = array(); foreach ($it as $k => $v) { $k = '"'. addcslashes($k, '"\\') . '"'; $v = _js_enc_value($v); $data[] = $assoc ? $key . ':' . $value : $value; } 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_uni_esc($value) . '"'; default: return $value; } } function _js_uni_esc($value) { $pattern = "/\r|(\n)|((?:[^\x09\x0A\x0D\x20-\x7E]{3})+)/"; return preg_replace_callback($pattern, '_js_uni_esc_cb', $value); } function _js_uni_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, stdClass, STDIN), 2 => array('a' => 'hoge', 'b' => 'foo'), ); echo 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.00718.68
8.3.50.0120.01021.99
8.3.40.0130.00318.80
8.3.30.0120.00918.95
8.3.20.0030.00520.20
8.3.10.0040.00422.09
8.3.00.0050.00322.52
8.2.180.0150.00618.29
8.2.170.0030.01222.96
8.2.160.0070.01120.91
8.2.150.0100.01024.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00417.75
8.2.110.0000.01021.02
8.2.100.0120.00017.91
8.2.90.0030.00619.21
8.2.80.0060.00317.97
8.2.70.0090.00317.63
8.2.60.0060.00317.92
8.2.50.0030.00618.07
8.2.40.0080.00018.16
8.2.30.0000.00818.09
8.2.20.0040.00417.73
8.2.10.0030.00519.53
8.2.00.0040.00417.77
8.1.280.0140.00325.92
8.1.270.0100.00324.02
8.1.260.0040.00426.35
8.1.250.0040.01428.09
8.1.240.0060.00323.73
8.1.230.0040.00819.17
8.1.220.0050.00317.74
8.1.210.0060.00318.77
8.1.200.0070.00317.23
8.1.190.0080.00017.53
8.1.180.0040.00418.10
8.1.170.0030.00618.58
8.1.160.0050.00222.02
8.1.150.0040.00418.61
8.1.140.0040.00417.36
8.1.130.0070.00017.71
8.1.120.0080.00017.49
8.1.110.0050.00317.35
8.1.100.0070.00017.44
8.1.90.0000.00817.43
8.1.80.0050.00317.47
8.1.70.0000.00817.40
8.1.60.0090.00017.44
8.1.50.0040.00417.35
8.1.40.0040.00417.46
8.1.30.0080.00017.64
8.1.20.0000.00817.54
8.1.10.0090.00017.43
8.1.00.0030.00517.48
8.0.300.0040.00418.77
8.0.290.0020.00517.18
8.0.280.0000.00718.58
8.0.270.0030.00317.30
8.0.260.0040.00416.96
8.0.250.0000.00717.06
8.0.240.0040.00416.95
8.0.230.0040.00417.06
8.0.220.0030.00316.91
8.0.210.0040.00416.90
8.0.200.0000.00716.92
8.0.190.0080.00017.00
8.0.180.0020.00516.91
8.0.170.0030.00617.03
8.0.160.0040.00416.93
8.0.150.0040.00417.00
8.0.140.0040.00416.85
8.0.130.0000.00713.40
8.0.120.0040.00416.88
8.0.110.0050.00316.95
8.0.100.0040.00417.05
8.0.90.0030.00517.11
8.0.80.0160.00316.95
8.0.70.0030.00516.96
8.0.60.0000.00716.88
8.0.50.0040.00416.90
8.0.30.0060.01217.26
8.0.20.0110.00817.40
8.0.10.0040.00416.94
8.0.00.0090.01216.76
7.4.330.0030.00315.02
7.4.320.0030.00316.49
7.4.300.0030.00316.63
7.4.290.0050.00216.61
7.4.280.0080.00016.64
7.4.270.0050.00516.56
7.4.260.0000.00716.57
7.4.250.0040.00416.47
7.4.240.0020.00616.59
7.4.230.0020.00516.74
7.4.220.0070.01316.63
7.4.210.0110.00316.53
7.4.200.0050.00316.75
7.4.190.0070.00016.72
7.4.160.0090.00616.52
7.4.150.0050.01017.40
7.4.140.0080.01217.86
7.4.130.0070.01016.56
7.4.120.0100.00816.61
7.4.110.0130.00716.59
7.4.100.0060.01416.76
7.4.90.0130.01016.64
7.4.80.0100.01016.57
7.4.70.0190.00316.35
7.4.60.0130.00616.70
7.4.50.0030.00316.57
7.4.40.0040.01122.77
7.4.30.0130.00316.44
7.4.00.0100.00315.09
7.3.330.0000.00513.38
7.3.320.0030.00313.36
7.3.310.0000.00716.35
7.3.300.0000.00716.32
7.3.290.0090.00916.32
7.3.280.0040.01416.33
7.3.270.0120.01617.40
7.3.260.0090.00916.37
7.3.250.0090.01216.52
7.3.240.0080.01516.34
7.3.230.0190.00316.39
7.3.210.0040.01416.34
7.3.200.0130.00719.39
7.3.190.0110.00616.48
7.3.180.0120.00316.36
7.3.170.0070.01616.55
7.3.160.0060.01116.43
7.3.120.0090.00614.90
7.2.330.0150.02016.71
7.2.320.0110.00716.54
7.2.310.0090.00916.70
7.2.300.0140.00316.69
7.2.290.0080.00816.81
7.2.60.0030.01016.77
7.2.00.0000.01619.46
7.1.200.0100.00315.66
7.1.100.0030.00718.16
7.1.70.0040.00416.70
7.1.60.0090.01619.82
7.1.50.0030.01716.91
7.1.00.0070.07322.36
7.0.200.0080.00416.43
7.0.140.0130.06322.17
7.0.90.0270.04019.96
7.0.80.0330.04019.95
7.0.70.0230.04319.94
7.0.60.0400.03719.95
7.0.50.0130.04320.29
7.0.40.0030.04719.95
7.0.30.0130.08020.11
7.0.20.0070.08020.14
7.0.10.0100.08020.07
7.0.00.0070.08720.09
5.6.280.0100.06721.06
5.6.240.0100.04020.61
5.6.230.0030.06320.59
5.6.220.0100.03720.48
5.6.210.0070.07320.60
5.6.200.0170.05020.98
5.6.190.0200.02321.06
5.6.180.0030.06020.96
5.6.170.0100.05021.07
5.6.160.0030.05321.04
5.6.150.0030.08321.05
5.6.140.0030.08021.04
5.6.130.0100.06321.18
5.6.120.0030.05021.05
5.6.110.0030.04320.98
5.6.100.0070.07021.00
5.6.90.0100.04321.13
5.6.80.0070.08020.51
5.6.70.0070.07720.44
5.6.60.0100.08020.53
5.6.50.0230.06320.46
5.6.40.0000.05320.50
5.6.30.0030.08020.42
5.6.20.0030.07720.39
5.6.10.0030.05320.40
5.6.00.0000.08320.52
5.5.380.0030.04320.57
5.5.370.0000.04320.47
5.5.360.0070.03720.32
5.5.350.0030.05720.44
5.5.340.0070.03720.85
5.5.330.0130.06020.89
5.5.320.0130.03020.94
5.5.310.0130.07720.77
5.5.300.0030.09020.79
5.5.290.0100.05320.89
5.5.280.0130.07720.84
5.5.270.0100.07720.78
5.5.260.0070.08020.86
5.5.250.0000.07320.69
5.5.240.0100.07720.34
5.5.230.0070.05020.23
5.5.220.0100.07720.11
5.5.210.0100.04720.17
5.5.200.0130.04020.18
5.5.190.0170.05720.19
5.5.180.0200.07320.13
5.5.160.0100.08020.20
5.5.150.0030.07720.00
5.5.140.0000.05320.25
5.5.130.0100.07320.20
5.5.120.0130.07320.29
5.5.110.0070.06320.27
5.5.100.0070.05320.10
5.5.90.0100.06020.02
5.5.80.0130.06720.10
5.5.70.0070.04720.05
5.5.60.0030.04320.08
5.5.50.0130.07020.07
5.5.40.0070.06720.09
5.5.30.0100.05020.16
5.5.20.0100.08019.97
5.5.10.0070.06720.07
5.5.00.0200.06719.94
5.4.450.0170.07319.38
5.4.440.0100.03719.45
5.4.430.0100.06319.37
5.4.420.0030.08319.53
5.4.410.0100.06319.23
5.4.400.0170.06719.13
5.4.390.0070.07719.14
5.4.380.0070.04319.03
5.4.370.0000.08319.12
5.4.360.0100.08019.04
5.4.350.0100.06318.92
5.4.340.0170.04019.04
5.4.320.0100.07319.13
5.4.310.0100.04319.16
5.4.300.0030.08019.08
5.4.290.0130.07319.17
5.4.280.0070.06319.18
5.4.270.0170.07319.18
5.4.260.0030.08319.18
5.4.250.0070.05319.04
5.4.240.0030.04319.11
5.4.230.0170.06719.04
5.4.220.0030.08018.93
5.4.210.0070.08319.00
5.4.200.0170.06319.13
5.4.190.0100.08719.02
5.4.180.0100.07019.25
5.4.170.0070.07719.03
5.4.160.0000.06319.02
5.4.150.0170.04319.03
5.4.140.0030.07716.35
5.4.130.0070.07316.41
5.4.120.0130.04716.43
5.4.110.0170.03316.57
5.4.100.0070.05716.56
5.4.90.0070.06716.45
5.4.80.0030.07316.48
5.4.70.0030.08016.39
5.4.60.0100.04316.46
5.4.50.0030.06316.46
5.4.40.0130.05016.46
5.4.30.0070.05016.39
5.4.20.0000.08316.46
5.4.10.0030.05316.47
5.4.00.0070.07315.81
5.3.290.0070.04714.81
5.3.280.0030.08314.76
5.3.270.0070.05314.60
5.3.260.0030.08314.53
5.3.250.0070.05014.75
5.3.240.0070.05714.69
5.3.230.0100.07014.67
5.3.220.0070.07314.73
5.3.210.0030.04314.60
5.3.200.0070.04014.67
5.3.190.0100.06714.55
5.3.180.0100.04014.62
5.3.170.0100.08014.68
5.3.160.0130.06314.71
5.3.150.0000.04314.64
5.3.140.0100.07014.50
5.3.130.0130.07714.56
5.3.120.0130.06714.70
5.3.110.0070.07714.64
5.3.100.0030.08014.02
5.3.90.0100.07013.99
5.3.80.0030.08314.15
5.3.70.0030.08314.13
5.3.60.0070.07714.04
5.3.50.0130.06714.09
5.3.40.0100.06714.08
5.3.30.0070.07313.96
5.3.20.0000.04313.66
5.3.10.0070.07013.57
5.3.00.0030.04013.70
5.2.170.0070.05311.28
5.2.160.0100.05711.28
5.2.150.0030.04311.31
5.2.140.0070.04311.30
5.2.130.0030.03311.06
5.2.120.0070.05711.13
5.2.110.0000.03711.18
5.2.100.0030.05311.16
5.2.90.0070.02711.01
5.2.80.0070.02711.15
5.2.70.0070.02711.15
5.2.60.0030.06710.94
5.2.50.0070.06011.08
5.2.40.0030.04710.93
5.2.30.0070.06011.06
5.2.20.0030.05711.05
5.2.10.0100.06010.75
5.2.00.0100.05310.85
5.1.60.0030.03710.08
5.1.50.0100.0509.86
5.1.40.0030.04010.00
5.1.30.0070.05010.40
5.1.20.0070.05310.45
5.1.10.0030.04310.22
5.1.00.0000.04010.11
5.0.50.0030.0478.65
5.0.40.0100.0378.58
5.0.30.0030.0538.37
5.0.20.0100.0408.33
5.0.10.0000.0478.25
5.0.00.0070.0638.28
4.4.90.0030.0377.44
4.4.80.0030.0377.44
4.4.70.0030.0337.44
4.4.60.0070.0337.44
4.4.50.0070.0277.44
4.4.40.0000.0577.44
4.4.30.0070.0337.44
4.4.20.0000.0277.44
4.4.10.0000.0277.44
4.4.00.0000.0577.44
4.3.110.0070.0337.44
4.3.100.0030.0207.44
4.3.90.0000.0377.44
4.3.80.0030.0507.44
4.3.70.0000.0377.44
4.3.60.0000.0307.44
4.3.50.0030.0337.44
4.3.40.0000.0507.44
4.3.30.0030.0337.44
4.3.20.0030.0307.44
4.3.10.0000.0377.44
4.3.00.0030.0337.44

preferences:
41.79 ms | 401 KiB | 5 Q