@ 2013-07-08T17:24:49Z <?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) {
static $pattern = "@[\a\b\f\n\r\t\"'/]|([^\x09\x0A\x0D\x20-\x7E|]{3}|\\0|" . chr(11) . ")+@";
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], "\a\b\f\n\r\t\"'/");
}
}
}
echo json_encode(array('&/"\''=>"\0\a\b\f\n\r\t" . chr(11)));
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.018 0.043 12.40 5.4.16 0.016 0.043 12.40 5.4.15 0.016 0.044 12.39 5.4.14 0.017 0.043 12.08 5.4.13 0.017 0.045 12.07 5.4.12 0.025 0.064 12.03 5.4.11 0.021 0.046 12.03 5.4.10 0.025 0.071 12.03 5.4.9 0.018 0.042 12.03 5.4.8 0.015 0.045 12.03 5.4.7 0.018 0.041 12.02 5.4.6 0.015 0.043 12.03 5.4.5 0.017 0.040 12.02 5.4.4 0.020 0.054 12.01 5.4.3 0.015 0.044 12.00 5.4.2 0.019 0.054 12.00 5.4.1 0.027 0.063 12.00 5.4.0 0.024 0.064 11.49 5.3.26 0.026 0.068 12.72 5.3.25 0.005 0.038 12.72 5.3.24 0.026 0.067 12.72 5.3.23 0.021 0.043 12.71 5.3.22 0.028 0.063 12.68 5.3.21 0.020 0.043 12.68 5.3.20 0.026 0.064 12.68 5.3.19 0.034 0.089 12.67 5.3.18 0.026 0.065 12.67 5.3.17 0.027 0.065 12.67 5.3.16 0.015 0.045 12.67 5.3.15 0.027 0.065 12.67 5.3.14 0.025 0.080 12.66 5.3.13 0.019 0.043 12.65 5.3.12 0.023 0.055 12.66 5.3.11 0.023 0.054 12.66 5.3.10 0.023 0.068 12.13 5.3.9 0.034 0.060 12.12 5.3.8 0.018 0.046 12.10 5.3.7 0.019 0.045 12.10 5.3.6 0.029 0.064 12.09 5.3.5 0.032 0.076 12.04 5.3.4 0.025 0.064 12.04 5.3.3 0.015 0.046 12.01 5.3.2 0.025 0.065 11.79 5.3.1 0.015 0.045 11.74 5.3.0 0.022 0.066 11.73
preferences:dark mode live preview
140.2 ms | 1394 KiB | 7 Q