note 102872 deleted from function.json-encode by danbrown
| From: | danbrown@php.net | Date: | Fri, 11 Mar 2011 14:48:39 +0000 |
| Subject: | note 102872 deleted from function.json-encode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177793@lists.php.net to get a copy of this message | ||
Note Submitter: usulaco at gmail dot com
----
This maybe usefull
function json_encode_alt($array) {
$out .= '{';
foreach($array as $key => $value){
if(!is_array($value))
$out .= '"'.$key.'" :
"'.preg_replace("!([\b\t\n\r\f\"\\'])!", "\\\\\\1",
$value).'",';
else
$out .= '"'.$key.'" : '.json_encode_alt($value);
}
$out = trim($out,',');
return $out.'}';
}