note 96958 added to function.json-decode
| From: | kishor_kn at hotmail dot com | Date: | Thu, 25 Mar 2010 05:35:18 +0000 |
| Subject: | note 96958 added to function.json-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167372@lists.php.net to get a copy of this message | ||
/**
* the decodeJSON works for the JSON string of the form
* {
* "7":{
* "questionId":"7",
* "category":"1",
* "id":"38",
* "texts":"%"
* },
* "6":{
* "questionId":"6",
* "category":"4",
* "id":"45",
* "texts":"%"
* }
* }
* @param $JSONstring
* @return returns an array after successful conversion
* returns false if supplied JSONstring is empty
*/
function decodeJSON($JSONstring) {
if(!empty($JSONstring)) {
$objectString = json_decode($JSONstring);
$count = 0;
foreach($objectString as $data) {
foreach($data as $arrayIndex => $vals) {
$newData[$count][$arrayIndex] = $vals;
}
$count++;
}
return ($newData);
}
return false;
}
----
Server IP: 69.147.83.197
Probable Submitter: 113.199.137.189
----
Manual Page -- http://www.php.net/manual/en/function.json-decode.php
Edit -- https://master.php.net/note/edit/96958
Del: integrated -- https://master.php.net/note/delete/96958/integrated
Del: useless -- https://master.php.net/note/delete/96958/useless
Del: bad code -- https://master.php.net/note/delete/96958/bad+code
Del: spam -- https://master.php.net/note/delete/96958/spam
Del: non-english -- https://master.php.net/note/delete/96958/non-english
Del: in docs -- https://master.php.net/note/delete/96958/in+docs
Del: other reasons-- https://master.php.net/note/delete/96958
Reject -- https://master.php.net/note/reject/96958
Search -- https://master.php.net/manage/user-notes.php