@ 2013-07-08T17:44:04Z <?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\"'/");
}
}
}
echo json_encode(array('&/"\''=>"\0\f\n\r\t\e" . chr(17)."1"));
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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).
Version System time (s) User time (s) Memory (MiB) 5.4.17 0.010 0.047 19.14 5.4.16 0.007 0.060 19.15 5.4.15 0.003 0.053 19.22 5.4.14 0.003 0.060 16.48 5.4.13 0.010 0.043 16.44 5.4.12 0.003 0.060 16.59 5.4.11 0.003 0.037 16.50 5.4.10 0.003 0.043 16.51 5.4.9 0.013 0.060 16.33 5.4.8 0.013 0.067 16.31 5.4.7 0.007 0.050 16.42 5.4.6 0.003 0.077 16.63 5.4.5 0.017 0.060 16.48 5.4.4 0.013 0.067 16.43 5.4.3 0.007 0.033 16.26 5.4.2 0.003 0.073 16.26 5.4.1 0.007 0.073 16.64 5.4.0 0.007 0.070 15.76 5.3.26 0.010 0.070 14.63 5.3.25 0.007 0.070 14.66 5.3.24 0.010 0.033 14.62 5.3.23 0.007 0.037 14.68 5.3.22 0.000 0.063 14.62 5.3.21 0.013 0.073 14.58 5.3.20 0.010 0.073 14.61 5.3.19 0.003 0.040 14.51 5.3.18 0.010 0.043 14.66 5.3.17 0.007 0.073 14.58 5.3.16 0.003 0.060 14.64 5.3.15 0.003 0.043 14.48 5.3.14 0.007 0.073 14.63 5.3.13 0.007 0.043 14.64 5.3.12 0.007 0.073 14.60 5.3.11 0.007 0.050 14.46 5.3.10 0.000 0.080 14.07 5.3.9 0.017 0.067 13.96 5.3.8 0.007 0.070 14.07 5.3.7 0.013 0.067 14.09 5.3.6 0.010 0.047 14.03 5.3.5 0.013 0.063 14.02 5.3.4 0.000 0.040 14.04 5.3.3 0.007 0.037 13.88 5.3.2 0.007 0.047 13.77 5.3.1 0.003 0.057 13.74 5.3.0 0.007 0.070 13.71
preferences:dark mode live preview
144.68 ms | 1394 KiB | 7 Q