note 96169 modified in function.json-decode by danbrown

From: Date: Fri, 12 Feb 2010 02:45:42 +0000
Subject: note 96169 modified in function.json-decode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165897@lists.php.net to get a copy of this message
If var_dump produces NULL, you may be experiencing JSONP aka JSON with padding, here's a quick fix... <?php //remove padding $body=preg_replace('/.+?({.+}).+/','$1',$body); // now, process the JSON string $result = json_decode($body); var_dump($result); ?> --was-- If var_dump produces NULL, you may be experiencing JSONP aka JSON with padding, here's a quick fix... <?php //remove padding $body=preg_replace('/.+?({.+}).+/','$1',$body); // now, process the JSON string $result = json_decode($body); var_dump($result); http://php.net/manual/en/function.json-decode.php

« previous php.notes (#165897) next »