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 = "@[\x09\x0a\x0b\x0d\"'/]|([^\x09\x0a\x0d\x20-\x7e|]{3}|\\0|%s)+@"; 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], "\f\n\r\t\"'/"); } } } $str = ''; for ($i=1;$i<=32;$i++) { $str .= chr($i); } $str .= chr(127); echo json_encode(array('&/"\''=>$str));

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.70.0040.01116.88
8.3.60.0100.01316.88
8.3.50.0120.01022.12
8.3.40.0120.00318.97
8.3.30.0100.00719.21
8.3.20.0140.00420.38
8.3.10.0020.00523.65
8.3.00.0080.00019.50
8.2.180.0100.01318.26
8.2.170.0070.01022.96
8.2.160.0030.01120.26
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0080.01226.16
8.2.120.0080.00022.16
8.2.110.0090.00020.84
8.2.100.0080.00317.84
8.2.90.0040.00417.91
8.2.80.0030.00917.97
8.2.70.0030.00617.75
8.2.60.0040.00418.03
8.2.50.0000.00818.07
8.2.40.0050.00318.34
8.2.30.0070.00018.05
8.2.20.0000.00817.92
8.2.10.0000.00718.13
8.2.00.0000.00717.74
8.1.280.0110.01125.92
8.1.270.0040.00423.97
8.1.260.0080.00026.35
8.1.250.0050.00328.09
8.1.240.0100.00022.48
8.1.230.0040.00820.97
8.1.220.0030.00517.77
8.1.210.0000.00918.86
8.1.200.0060.00317.47
8.1.190.0080.00017.43
8.1.180.0040.00418.10
8.1.170.0040.00418.63
8.1.160.0000.00822.07
8.1.150.0080.00018.73
8.1.140.0000.00717.52
8.1.130.0040.00417.79
8.1.120.0050.00217.46
8.1.110.0080.00017.37
8.1.100.0000.00817.52
8.1.90.0070.00017.54
8.1.80.0080.00017.41
8.1.70.0040.00417.52
8.1.60.0000.00917.68
8.1.50.0030.00517.49
8.1.40.0050.00317.57
8.1.30.0040.00417.64
8.1.20.0070.00017.63
8.1.10.0000.00817.70
8.1.00.0000.00817.57
8.0.300.0000.00819.83
8.0.290.0000.00717.14
8.0.280.0000.00718.54
8.0.270.0070.00017.24
8.0.260.0030.00316.89
8.0.250.0040.00416.94
8.0.240.0060.00316.88
8.0.230.0030.00316.91
8.0.220.0050.00316.86
8.0.210.0040.00416.92
8.0.200.0030.00316.96
8.0.190.0000.00716.89
8.0.180.0000.00717.02
8.0.170.0000.00816.91
8.0.160.0000.00716.86
8.0.150.0000.00716.86
8.0.140.0000.00816.82
8.0.130.0030.00313.35
8.0.120.0030.00616.88
8.0.110.0000.00716.86
8.0.100.0050.00216.84
8.0.90.0050.00216.96
8.0.80.0120.00316.91
8.0.70.0000.00716.82
8.0.60.0030.00617.03
8.0.50.0030.00516.95
8.0.30.0090.01017.10
8.0.20.0090.00917.40
8.0.10.0070.00016.98
8.0.00.0150.00616.74
7.4.330.0030.00315.10
7.4.320.0060.00016.50
7.4.300.0000.00616.57
7.4.290.0030.00316.44
7.4.280.0000.00716.65
7.4.270.0030.00316.57
7.4.260.0040.00416.50
7.4.250.0040.00416.46
7.4.240.0020.00516.60
7.4.230.0050.00316.67
7.4.220.0100.01016.43
7.4.210.0070.01016.64
7.4.200.0000.00716.50
7.4.190.0040.00416.46
7.4.160.0060.01016.54
7.4.150.0190.00017.40
7.4.140.0100.00717.86
7.4.130.0120.00516.49
7.4.120.0080.01416.50
7.4.110.0100.00616.61
7.4.100.0070.01016.66
7.4.90.0090.00916.36
7.4.80.0100.00719.39
7.4.70.0170.00016.59
7.4.60.0070.01016.53
7.4.50.0030.00316.27
7.4.40.0100.00622.77
7.4.30.0170.00016.71
7.4.10.0070.00915.02
7.4.00.0060.01114.98
7.3.330.0000.00613.39
7.3.320.0000.00813.45
7.3.310.0070.00016.32
7.3.300.0030.00316.35
7.3.290.0030.01016.53
7.3.280.0090.00816.45
7.3.270.0120.00617.40
7.3.260.0150.00816.49
7.3.250.0080.01216.32
7.3.240.0140.00316.70
7.3.230.0060.01216.70
7.3.210.0040.01316.40
7.3.200.0140.00419.39
7.3.190.0130.01016.67
7.3.180.0030.01416.38
7.3.170.0110.00516.44
7.3.160.0090.01316.51
7.3.130.0090.01014.93
7.3.120.0040.01214.96
7.3.110.0070.01014.85
7.3.100.0050.01014.89
7.3.90.0090.00614.86
7.3.80.0060.00815.16
7.3.70.0080.00614.70
7.3.60.0060.00814.82
7.3.50.0050.01015.03
7.3.40.0020.01314.62
7.3.30.0040.00914.87
7.3.20.0020.01116.72
7.3.10.0040.00816.63
7.3.00.0070.00616.68
7.2.330.0030.01516.78
7.2.320.0060.01116.47
7.2.310.0100.00716.54
7.2.300.0040.01316.73
7.2.290.0120.01216.72
7.2.260.0070.01115.13
7.2.250.0070.01214.98
7.2.240.0090.00615.24
7.2.230.0030.01214.99
7.2.220.0080.00915.07
7.2.210.0030.01014.79
7.2.200.0060.00815.04
7.2.190.0030.01015.04
7.2.180.0060.01115.11
7.2.170.0050.00815.05
7.2.160.0090.00514.92
7.2.150.0090.00616.90
7.2.140.0080.00616.79
7.2.130.0070.00916.93
7.2.120.0020.01216.95
7.2.110.0030.01116.91
7.2.100.0070.00516.76
7.2.90.0100.00616.95
7.2.80.0050.01216.82
7.2.70.0030.01216.95
7.2.60.0060.00816.76
7.2.50.0060.00716.93
7.2.40.0050.01216.86
7.2.30.0070.00717.07
7.2.20.0060.00817.04
7.2.10.0080.00716.75
7.2.00.0030.01117.74
7.1.330.0060.00915.87
7.1.320.0080.00515.85
7.1.310.0060.00815.84
7.1.300.0030.00915.69
7.1.290.0030.00715.76
7.1.280.0090.00415.91
7.1.270.0100.00515.89
7.1.260.0050.00815.71
7.1.250.0050.00915.88
7.1.240.0040.00915.82
7.1.230.0070.00415.90
7.1.220.0060.00815.91
7.1.210.0040.01015.85
7.1.200.0060.00615.88
7.1.190.0050.00915.60
7.1.180.0030.00815.88
7.1.170.0040.01115.88
7.1.160.0090.00315.72
7.1.150.0020.01215.83
7.1.140.0060.00515.87
7.1.130.0020.01415.92
7.1.120.0030.00815.81
7.1.110.0070.00715.72
7.1.100.0020.01016.58
7.1.90.0100.00515.89
7.1.80.0020.01215.82
7.1.70.0050.01016.28
7.1.60.0050.01116.91
7.1.50.0070.00916.14
7.1.40.0060.00715.69
7.1.30.0060.00815.82
7.1.20.0030.00915.66
7.1.10.0090.00615.88
7.1.00.0070.03117.99
7.0.330.0100.00515.33
7.0.320.0030.01015.45
7.0.310.0080.00315.49
7.0.300.0070.00915.52
7.0.290.0090.00615.40
7.0.280.0020.00915.27
7.0.270.0050.00715.47
7.0.260.0050.00715.38
7.0.250.0060.00615.26
7.0.240.0060.00515.44
7.0.230.0070.00815.38
7.0.220.0080.00315.41
7.0.210.0060.00615.24
7.0.200.0050.00815.80
7.0.190.0080.00315.47
7.0.180.0030.01015.33
7.0.170.0020.01215.52
7.0.160.0030.01015.36
7.0.150.0060.00515.49
7.0.140.0020.02917.67
7.0.130.0110.00315.37
7.0.120.0060.00715.41
7.0.110.0050.00915.40
7.0.100.0030.01015.15
7.0.90.0120.03016.86
7.0.80.0280.01817.00
7.0.70.0250.02116.94
7.0.60.0250.03316.88
7.0.50.0160.03217.07
7.0.40.0050.02015.63
7.0.30.0070.03015.72
7.0.20.0040.03415.65
7.0.10.0020.02215.75
7.0.00.0060.02115.65
5.6.400.0030.00914.20
5.6.390.0080.00714.67
5.6.380.0090.00514.17
5.6.370.0060.00714.20
5.6.360.0050.00814.52
5.6.350.0030.00914.55
5.6.340.0100.00214.40
5.6.330.0060.00914.48
5.6.320.0070.00614.30
5.6.310.0020.01314.53
5.6.300.0040.01014.22
5.6.290.0070.00614.24
5.6.280.0020.03216.61
5.6.270.0000.01414.48
5.6.260.0050.01214.32
5.6.250.0030.01214.58
5.6.240.0050.03616.61
5.6.230.0090.03216.47
5.6.220.0050.03216.46
5.6.210.0080.02016.48
5.6.200.0080.02716.49
5.6.190.0030.02116.60
5.6.180.0080.03016.63
5.6.170.0080.02216.71
5.6.160.0070.01616.61
5.6.150.0060.02616.51
5.6.140.0050.03016.48
5.6.130.0040.02316.65
5.6.120.0110.02916.56
5.6.110.0090.03016.54
5.6.100.0090.02516.71
5.6.90.0080.03116.70
5.6.80.0040.02116.28
5.6.70.0030.02216.23
5.6.60.0070.03016.24
5.6.50.0050.02316.28
5.6.40.0080.02816.39
5.6.30.0090.02416.29
5.6.20.0050.03116.35
5.6.10.0110.02616.37
5.6.00.0080.01916.34
5.5.380.0080.03416.33
5.5.370.0040.02216.29
5.5.360.0050.03316.46
5.5.350.0080.03116.40
5.5.340.0070.03216.45
5.5.330.0030.03716.53
5.5.320.0040.02916.45
5.5.310.0040.03216.59
5.5.300.0090.02816.54
5.5.290.0070.03116.51
5.5.280.0080.03116.58
5.5.270.0070.03216.61
5.5.260.0050.03116.72
5.5.250.0070.01816.26
5.5.240.0070.02916.37
5.5.230.0040.03316.32
5.5.220.0050.02216.27
5.5.210.0070.02816.16
5.5.200.0060.02216.17
5.5.190.0050.02816.14
5.5.180.0060.03216.35
5.5.170.0070.00514.22
5.5.160.0070.03016.32
5.5.150.0110.02616.16
5.5.140.0070.03016.13
5.5.130.0070.03116.42
5.5.120.0080.02116.27
5.5.110.0080.03016.15
5.5.100.0060.02616.13
5.5.90.0050.03416.07
5.5.80.0080.02216.23
5.5.70.0100.02916.28
5.5.60.0050.02516.12
5.5.50.0090.03016.24
5.5.40.0010.03116.12
5.5.30.0030.03616.10
5.5.20.0090.02716.34
5.5.10.0060.02216.19
5.5.00.0070.01916.02
5.4.450.0060.02714.12
5.4.440.0040.02914.04
5.4.430.0060.02514.10
5.4.420.0040.02914.10
5.4.410.0030.02914.12
5.4.400.0080.02713.99
5.4.390.0060.03414.10
5.4.380.0040.02014.05
5.4.370.0030.03014.02
5.4.360.0090.01314.00
5.4.350.0040.02814.00
5.4.340.0060.01614.01
5.4.330.0060.00311.36
5.4.320.0070.02613.91
5.4.310.0050.01713.97
5.4.300.0040.03114.07
5.4.290.0040.02613.92
5.4.280.0060.02114.01
5.4.270.0060.02414.03
5.4.260.0040.03213.92
5.4.250.0070.02513.93
5.4.240.0060.01613.99
5.4.230.0040.03014.01
5.4.220.0070.02813.88
5.4.210.0050.02713.88
5.4.200.0060.02513.91
5.4.190.0070.02913.94
5.4.180.0050.02913.97
5.4.170.0100.01513.99
5.4.160.0070.01513.89
5.4.150.0040.02813.91
5.4.140.0050.01812.97
5.4.130.0010.02713.16
5.4.120.0060.02613.20
5.4.110.0060.02813.15
5.4.100.0060.01513.17
5.4.90.0050.01513.13
5.4.80.0080.01813.02
5.4.70.0030.02813.16
5.4.60.0050.02713.14
5.4.50.0040.02413.11
5.4.40.0030.02712.98
5.4.30.0080.01813.06
5.4.20.0020.02313.14
5.4.10.0060.02513.15
5.4.00.0080.02612.91
5.3.290.0060.03012.36
5.3.280.0060.02112.37
5.3.270.0020.02312.41
5.3.260.0040.03112.27
5.3.250.0040.02912.38
5.3.240.0060.02812.35
5.3.230.0020.03212.38
5.3.220.0080.01712.29
5.3.210.0080.02912.32
5.3.200.0060.02112.39
5.3.190.0060.01712.37
5.3.180.0050.02212.35
5.3.170.0040.03012.37
5.3.160.0040.03112.36
5.3.150.0020.02812.39
5.3.140.0020.02612.37
5.3.130.0050.02712.26
5.3.120.0030.03212.37
5.3.110.0070.02712.29
5.3.100.0050.02312.15
5.3.90.0090.01812.20
5.3.80.0040.02612.10
5.3.70.0070.02012.15
5.3.60.0050.03012.16
5.3.50.0070.02212.10
5.3.40.0060.02812.05
5.3.30.0050.02812.09
5.3.20.0080.02111.96
5.3.10.0040.02711.95
5.3.00.0070.02711.91
5.2.170.0070.05711.24
5.2.160.0030.05311.29
5.2.150.0030.07011.31
5.2.140.0070.06711.21
5.2.130.0100.05711.20
5.2.120.0070.03311.23
5.2.110.0030.03710.99
5.2.100.0100.05711.16
5.2.90.0070.05711.00
5.2.80.0070.03311.18
5.2.70.0070.06011.01
5.2.60.0070.04311.09
5.2.50.0130.05710.98
5.2.40.0030.06311.10
5.2.30.0030.03711.03
5.2.20.0170.02310.95
5.2.10.0100.04010.90
5.2.00.0030.06010.77
5.1.60.0070.05010.55
5.1.50.0070.04710.55
5.1.40.0000.05010.55
5.1.30.0070.04710.55
5.1.20.0100.05010.55
5.1.10.0030.04710.55
5.1.00.0100.05010.55
5.0.50.0000.03010.55
5.0.40.0030.04310.55
5.0.30.0030.06010.55
5.0.20.0000.03710.55
5.0.10.0070.04010.55
5.0.00.0170.05310.55
4.4.90.0000.03710.55
4.4.80.0000.04010.55
4.4.70.0030.02710.55
4.4.60.0070.02710.55
4.4.50.0030.03010.55
4.4.40.0000.05310.55
4.4.30.0000.02310.55
4.4.20.0030.02710.55
4.4.10.0000.02710.55
4.4.00.0030.03310.55
4.3.110.0030.03310.55
4.3.100.0000.03710.55
4.3.90.0030.03710.55
4.3.80.0030.05010.55
4.3.70.0000.02310.55
4.3.60.0000.03710.55
4.3.50.0070.03010.55
4.3.40.0070.04310.55
4.3.30.0030.03310.55
4.3.20.0030.03310.55
4.3.10.0000.03710.55
4.3.00.0000.03710.55

preferences:
64.05 ms | 401 KiB | 5 Q