note 100738 added to function.json-decode
| From: | jamespam at hotmail dot com | Date: | Wed, 03 Nov 2010 18:56:17 +0000 |
| Subject: | note 100738 added to function.json-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173721@lists.php.net to get a copy of this message | ||
decode json (with array data) to php array PHP<5
<?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] == '"') $comment = !$comment;
}
debug($out);
eval($out . ';');
return $x;
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 74.219.190.234
----
Manual Page -- http://www.php.net/manual/en/function.json-decode.php
Edit -- https://master.php.net/note/edit/100738
Del: integrated -- https://master.php.net/note/delete/100738/integrated
Del: useless -- https://master.php.net/note/delete/100738/useless
Del: bad code -- https://master.php.net/note/delete/100738/bad+code
Del: spam -- https://master.php.net/note/delete/100738/spam
Del: non-english -- https://master.php.net/note/delete/100738/non-english
Del: in docs -- https://master.php.net/note/delete/100738/in+docs
Del: other reasons-- https://master.php.net/note/delete/100738
Reject -- https://master.php.net/note/reject/100738
Search -- https://master.php.net/manage/user-notes.php