@ 2013-07-08T17:43:29Z <?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\x0\x0b\"'/]|([^\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.003 0.067 19.14 5.4.16 0.010 0.063 18.90 5.4.15 0.013 0.073 18.96 5.4.14 0.007 0.073 16.48 5.4.13 0.007 0.067 16.44 5.4.12 0.007 0.070 16.46 5.4.11 0.007 0.073 16.72 5.4.10 0.007 0.073 16.48 5.4.9 0.007 0.043 16.47 5.4.8 0.003 0.057 16.59 5.4.7 0.003 0.060 16.33 5.4.6 0.010 0.070 16.46 5.4.5 0.007 0.077 16.27 5.4.4 0.007 0.060 16.40 5.4.3 0.000 0.077 16.45 5.4.2 0.007 0.073 16.44 5.4.1 0.013 0.067 16.40 5.4.0 0.007 0.073 15.95 5.3.26 0.013 0.037 14.70 5.3.25 0.017 0.053 14.70 5.3.24 0.017 0.033 14.66 5.3.23 0.003 0.040 14.62 5.3.22 0.003 0.040 14.60 5.3.21 0.010 0.073 14.63 5.3.20 0.003 0.040 14.61 5.3.19 0.007 0.060 14.51 5.3.18 0.007 0.040 14.74 5.3.17 0.007 0.053 14.59 5.3.16 0.000 0.047 14.58 5.3.15 0.010 0.057 14.59 5.3.14 0.003 0.050 14.60 5.3.13 0.000 0.073 14.62 5.3.12 0.007 0.043 14.62 5.3.11 0.007 0.043 14.61 5.3.10 0.013 0.067 14.23 5.3.9 0.020 0.063 14.08 5.3.8 0.007 0.067 14.11 5.3.7 0.007 0.043 14.07 5.3.6 0.000 0.047 14.03 5.3.5 0.007 0.053 14.04 5.3.4 0.003 0.080 14.02 5.3.3 0.003 0.070 13.98 5.3.2 0.017 0.043 13.72 5.3.1 0.007 0.033 13.73 5.3.0 0.007 0.067 13.69
preferences:dark mode live preview
136.83 ms | 1394 KiB | 7 Q