Advertisement
Guest User

Untitled

a guest
Oct 30th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1.         function json_decode($json)
  2.         {
  3.                 $comment = false;
  4.                 $out = '$x=';
  5.  
  6.                 for ($i=0; $i<strlen($json); $i++)
  7.                         {
  8.                         if (!$comment)
  9.                         {
  10.                                 if ($json[$i] == '{') $out .= ' array(';
  11.                                 else if ($json[$i] == '}') $out .= ')';
  12.                                 else if ($json[$i] == ':') $out .= '=>';
  13.                                 else $out .= $json[$i];
  14.                         }
  15.                         else $out .= $json[$i];
  16.                         if ($json[$i] == '"')    $comment = !$comment;
  17.                 }
  18.                 eval($out . ';');
  19.                 return $x;
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement