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 = _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 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 = "@[\\0\a\b\f\n\r\t\v\"'/]|([^\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], "\0\a\b\f\n\r\t\v\"'/"); } } } echo json_encode(array('&/"\''=>"\0\a\b\f\n\r\t\v"));

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.0100.01018.30
8.3.50.0090.00921.27
8.3.40.0100.01018.71
8.3.30.0110.00318.62
8.3.20.0060.00918.65
8.3.10.0080.00020.85
8.3.00.0040.00421.90
8.2.180.0090.00916.38
8.2.170.0080.00822.96
8.2.160.0070.01420.89
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00421.01
8.2.110.0100.00020.54
8.2.100.0040.00717.78
8.2.90.0040.00419.22
8.2.80.0080.00017.97
8.2.70.0080.00017.37
8.2.60.0000.00818.04
8.2.50.0030.00518.07
8.2.40.0080.00018.22
8.2.30.0040.00419.38
8.2.20.0040.00417.58
8.2.10.0050.00317.69
8.2.00.0070.00317.65
8.1.280.0190.00025.92
8.1.270.0050.00323.99
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0100.00022.42
8.1.230.0110.00020.89
8.1.220.0000.00918.77
8.1.210.0090.00018.97
8.1.200.0060.00317.25
8.1.190.0060.00317.40
8.1.180.0050.00318.10
8.1.170.0000.00818.70
8.1.160.0030.00518.80
8.1.150.0000.00818.64
8.1.140.0040.00417.45
8.1.130.0030.00317.76
8.1.120.0020.00517.50
8.1.110.0000.00717.42
8.1.100.0040.00417.39
8.1.90.0040.00417.35
8.1.80.0040.00417.37
8.1.70.0030.00317.41
8.1.60.0080.00317.60
8.1.50.0000.00817.45
8.1.40.0050.00217.48
8.1.30.0040.00417.65
8.1.20.0040.00417.54
8.1.10.0040.00417.52
8.1.00.0050.00317.41
8.0.300.0040.00419.98
8.0.290.0030.00617.16
8.0.280.0030.00318.45
8.0.270.0050.00317.18
8.0.260.0030.00316.77
8.0.250.0040.00416.92
8.0.240.0000.00816.95
8.0.230.0030.00516.95
8.0.220.0040.00416.81
8.0.210.0040.00416.90
8.0.200.0000.00616.87
8.0.190.0070.00016.86
8.0.180.0000.00716.89
8.0.170.0080.00016.88
8.0.160.0080.00016.82
8.0.150.0040.00416.93
8.0.140.0040.00716.75
8.0.130.0050.00013.35
8.0.120.0060.00316.82
8.0.110.0000.00716.78
8.0.100.0040.00416.89
8.0.90.0040.00416.72
8.0.80.0030.01116.88
8.0.70.0040.00416.75
8.0.60.0040.00416.82
8.0.50.0000.00716.90
8.0.30.0140.00517.25
8.0.20.0090.00917.40
8.0.10.0040.00416.91
8.0.00.0110.01016.75
7.4.330.0050.00016.73
7.4.320.0030.00316.53
7.4.300.0030.00316.46
7.4.290.0030.00316.66
7.4.280.0000.00716.50
7.4.270.0030.00316.58
7.4.260.0030.00313.29
7.4.250.0040.00416.51
7.4.240.0000.00716.48
7.4.230.0000.00716.35
7.4.220.0060.01316.52
7.4.210.0070.01016.50
7.4.200.0030.00316.43
7.4.190.0000.00816.61
7.4.160.0120.00416.43
7.4.150.0090.00917.40
7.4.140.0100.00917.86
7.4.130.0090.00916.52
7.4.120.0060.00916.43
7.4.110.0120.00616.47
7.4.100.0040.01816.49
7.4.90.0130.01016.48
7.4.80.0070.01019.39
7.4.70.0110.00716.37
7.4.60.0120.00616.36
7.4.50.0090.00016.31
7.4.40.0090.00622.77
7.4.30.0060.01016.59
7.4.00.0030.01414.84
7.3.330.0000.00613.11
7.3.320.0030.00313.12
7.3.310.0070.00016.11
7.3.300.0000.00716.12
7.3.290.0030.01216.27
7.3.280.0080.00816.23
7.3.270.0130.00317.40
7.3.260.0120.00718.24
7.3.250.0140.00516.44
7.3.240.0110.00516.53
7.3.230.0100.00716.50
7.3.210.0030.01316.32
7.3.200.0120.01019.39
7.3.190.0150.00616.38
7.3.180.0070.01016.29
7.3.170.0070.01016.36
7.3.160.0070.00816.20
7.3.120.0060.01014.53
7.3.00.0040.00716.53
7.2.330.0090.00916.47
7.2.320.0120.00916.66
7.2.310.0120.00616.21
7.2.300.0100.00716.50
7.2.290.0130.00416.56
7.2.130.0080.00416.49
7.2.120.0070.01116.51
7.2.110.0070.00716.90
7.2.100.0080.00816.80
7.2.90.0100.00716.87
7.2.80.0060.00316.84
7.2.70.0000.01116.85
7.2.60.0000.01016.74
7.2.50.0060.00916.84
7.2.40.0000.01016.97
7.2.30.0130.00316.69
7.2.20.0070.00716.73
7.2.10.0030.00816.86
7.2.00.0060.00717.94
7.1.250.0030.00715.52
7.1.240.0070.01015.39
7.1.230.0060.00315.71
7.1.220.0070.00715.62
7.1.210.0060.00315.50
7.1.200.0050.00815.75
7.1.190.0040.00415.57
7.1.180.0030.00915.50
7.1.170.0000.00815.75
7.1.160.0030.01515.63
7.1.150.0060.00615.58
7.1.140.0060.00315.64
7.1.130.0030.01015.39
7.1.120.0100.00015.72
7.1.110.0030.00915.63
7.1.100.0030.01016.92
7.1.90.0080.00315.61
7.1.80.0130.00315.61
7.1.70.0100.00616.27
7.1.60.0070.01017.54
7.1.50.0030.01616.26
7.1.40.0140.00015.42
7.1.30.0000.01215.68
7.1.20.0070.00315.43
7.1.10.0070.00715.68
7.1.00.0020.03118.97
7.0.330.0090.00315.00
7.0.320.0070.00715.05
7.0.310.0030.01015.17
7.0.300.0030.00715.18
7.0.290.0090.00315.05
7.0.280.0100.00315.38
7.0.270.0030.00615.29
7.0.260.0000.01215.27
7.0.250.0030.01015.02
7.0.240.0030.01015.36
7.0.230.0100.00315.02
7.0.220.0000.00915.11
7.0.210.0030.01015.35
7.0.200.0080.00515.74
7.0.190.0000.01215.34
7.0.180.0030.00614.99
7.0.170.0000.01615.37
7.0.160.0120.00315.26
7.0.150.0030.01015.16
7.0.140.0020.04318.64
7.0.130.0070.00715.11
7.0.120.0040.00815.30
7.0.110.0060.00615.02
7.0.100.0000.01215.33
7.0.90.0270.03017.63
7.0.80.0250.02917.67
7.0.70.0320.03817.61
7.0.60.0220.04217.66
7.0.50.0340.04717.80
7.0.40.0080.04416.76
7.0.30.0080.04516.83
7.0.20.0150.04016.74
7.0.10.0050.05116.74
7.0.00.0100.04016.51
5.6.380.0060.00314.27
5.6.370.0030.01014.38
5.6.360.0040.00714.18
5.6.350.0030.00914.36
5.6.340.0070.00714.50
5.6.330.0060.00314.54
5.6.320.0040.00714.27
5.6.310.0120.00613.92
5.6.300.0070.00714.08
5.6.290.0110.00414.34
5.6.280.0040.03917.60
5.6.270.0100.00614.45
5.6.260.0060.00614.21
5.6.250.0100.00313.89
5.6.240.0020.04717.42
5.6.230.0080.02817.54
5.6.220.0100.04217.26
5.6.210.0100.03817.41
5.6.200.0070.04217.65
5.6.190.0160.04217.59
5.6.180.0110.04017.67
5.6.170.0130.03817.58
5.6.160.0080.04717.68
5.6.150.0120.03217.72
5.6.140.0030.03017.62
5.6.130.0100.04317.78
5.6.120.0090.03017.60
5.6.110.0110.03217.69
5.6.100.0040.03517.54
5.6.90.0150.03517.63
5.6.80.0060.02317.35
5.6.70.0100.03817.40
5.6.60.0070.04017.24
5.6.50.0070.03717.25
5.6.40.0030.03017.35
5.6.30.0070.04017.16
5.6.20.0090.02317.32
5.6.10.0090.02717.27
5.6.00.0060.02117.29
5.5.380.0050.04815.76
5.5.370.0030.02715.66
5.5.360.0070.04215.71
5.5.350.0050.04215.83
5.5.340.0120.03815.89
5.5.330.0080.04115.89
5.5.320.0080.02215.97
5.5.310.0100.03716.02
5.5.300.0080.02715.85
5.5.290.0070.04216.00
5.5.280.0050.04415.89
5.5.270.0090.02515.95
5.5.260.0060.03615.95
5.5.250.0070.04315.73
5.5.240.0030.02315.62
5.5.230.0120.03515.64
5.5.220.0050.02515.60
5.5.210.0080.03715.55
5.5.200.0070.03515.65
5.5.190.0100.03815.66
5.5.180.0050.03615.68
5.5.170.0000.01311.00
5.5.160.0070.02715.43
5.5.150.0000.03715.55
5.5.140.0040.03015.47
5.5.130.0080.02615.50
5.5.120.0080.04015.60
5.5.110.0070.02515.63
5.5.100.0070.02415.54
5.5.90.0140.03515.45
5.5.80.0050.03515.63
5.5.70.0030.02615.50
5.5.60.0020.04715.50
5.5.50.0100.02215.39
5.5.40.0030.04315.65
5.5.30.0040.02915.47
5.5.20.0070.02215.43
5.5.10.0050.04315.50
5.5.00.0020.02915.62
5.4.450.0080.02515.08
5.4.440.0100.04015.14
5.4.430.0030.04615.22
5.4.420.0070.04215.24
5.4.410.0080.04314.94
5.4.400.0000.03315.15
5.4.390.0030.04515.07
5.4.380.0020.03914.89
5.4.370.0030.03914.96
5.4.360.0020.03414.94
5.4.350.0100.03714.72
5.4.340.0040.03115.06
5.4.330.0040.00410.99
5.4.320.0030.04115.10
5.4.310.0050.02214.97
5.4.300.0100.03514.88
5.4.290.0110.03515.01
5.4.280.0050.03015.05
5.4.270.0090.03715.06
5.4.260.0040.02914.98
5.4.250.0100.02814.79
5.4.240.0050.03314.96
5.4.230.0050.02114.82
5.4.220.0070.03015.03
5.4.210.0050.02014.97
5.4.200.0040.04114.92
5.4.190.0110.03815.11
5.4.180.0050.04014.93
5.4.170.0030.03415.07
5.4.160.0080.03815.00
5.4.150.0070.03714.91
5.4.140.0020.04313.56
5.4.130.0090.03913.73
5.4.120.0030.03613.36
5.4.110.0050.04113.73
5.4.100.0040.02913.51
5.4.90.0030.04013.74
5.4.80.0080.03213.73
5.4.70.0100.03713.68
5.4.60.0070.03813.69
5.4.50.0100.03713.69
5.4.40.0020.02513.69
5.4.30.0020.04013.69
5.4.20.0020.03813.52
5.4.10.0080.04013.41
5.4.00.0050.02813.16
5.3.290.0000.02612.59
5.3.280.0020.02912.52
5.3.270.0070.03912.69
5.3.260.0030.02412.73
5.3.250.0080.02812.51
5.3.240.0070.04112.54
5.3.230.0100.04012.61
5.3.220.0070.04212.53
5.3.210.0050.03112.51
5.3.200.0020.03112.41
5.3.190.0010.02812.58
5.3.180.0080.03612.67
5.3.170.0060.03512.65
5.3.160.0020.04512.61
5.3.150.0090.03912.67
5.3.140.0000.02712.51
5.3.130.0060.02812.63
5.3.120.0130.02212.63
5.3.110.0050.02312.48
5.3.100.0030.04012.34
5.3.90.0060.04012.37
5.3.80.0060.03812.22
5.3.70.0080.04012.19
5.3.60.0000.04412.27
5.3.50.0050.03912.24
5.3.40.0050.03212.29
5.3.30.0000.04412.13
5.3.20.0020.03711.99
5.3.10.0030.04212.01
5.3.00.0050.03012.05
5.2.170.0090.03010.72
5.2.160.0040.03410.77
5.2.150.0030.03610.66
5.2.140.0050.03310.72
5.2.130.0060.03010.72
5.2.120.0020.03510.65
5.2.110.0030.03110.76
5.2.100.0030.02910.75
5.2.90.0050.02010.72
5.2.80.0030.03310.71
5.2.70.0060.02110.72
5.2.60.0050.03210.70
5.2.50.0030.03510.71
5.2.40.0050.03110.64
5.2.30.0020.02810.67
5.2.20.0070.02810.58
5.2.10.0020.03210.53
5.2.00.0020.03210.53
5.1.60.0000.03010.16
5.1.50.0070.02510.18
5.1.40.0020.02910.05
5.1.30.0030.03010.30
5.1.20.0050.02810.25
5.1.10.0050.02710.21
5.1.00.0040.03110.18
5.0.50.0020.0239.42
5.0.40.0060.0139.35
5.0.30.0020.0329.31
5.0.20.0080.0189.25
5.0.10.0040.0259.30
5.0.00.0030.0339.24
4.4.90.0000.0169.20
4.4.80.0030.0129.20
4.4.70.0030.0139.20
4.4.60.0020.0129.20
4.4.50.0000.0159.20
4.4.40.0010.0289.20
4.4.30.0070.0159.20
4.4.20.0020.0179.20
4.4.10.0000.0229.20
4.4.00.0000.0319.20
4.3.110.0020.0199.20
4.3.100.0020.0209.20
4.3.90.0020.0209.20
4.3.80.0030.0219.20
4.3.70.0030.0179.20
4.3.60.0020.0139.20
4.3.50.0030.0189.20
4.3.40.0020.0289.20
4.3.30.0000.0199.20
4.3.20.0060.0159.20
4.3.10.0050.0159.20
4.3.00.0010.0159.20

preferences:
44.71 ms | 401 KiB | 5 Q