note 100740 deleted from function.json-decode by googleguy

From: Date: Fri, 30 Nov 2012 05:44:29 +0000
Subject: note 100740 deleted from function.json-decode by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192219@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- to deal with escaped dbl-quotes this is required: if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; revision is as follows: <?php if ( !function_exists('json_decode') ){ function json_decode($json) { $comment = false; $out = '$x='; for ($i=0; $i<strlen($json); $i++) { if (!$comment) { if (($json[$i] == '{') || ($json[$i] == '[')) $out .= ' array('; else if (($json[$i] == '}') || ($json[$i] == ']')) $out .= ')'; else if ($json[$i] == ':') $out .= '=>'; else $out .= $json[$i]; } else $out .= $json[$i]; if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; } eval($out . ';'); return $x; } } ?>

« previous php.notes (#192219) next »