note 94359 added to function.json-encode
| From: | rlz_ar at yahoo dot com | Date: | Fri, 30 Oct 2009 04:35:58 +0000 |
| Subject: | note 94359 added to function.json-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162273@lists.php.net to get a copy of this message | ||
If you have problems with json_encode() on arrays, you can force json_encode() to encode as object,
and then use json_decode() casting the result as array:
<?php
$myarray = Array('isa', 'dalawa', 'tatlo');
unset($myarray[1]);
$json_encoded_array = json_encode ( $myarray, JSON_FORCE_OBJECT );
// do whatever you want with your data
// then you can retrive the data doing:
$myarray = (array) json_decode ( $json_encoded_array );
?>
----
Server IP: 201.216.232.3
Probable Submitter: 201.231.233.146
----
Manual Page -- http://www.php.net/manual/en/function.json-encode.php
Edit -- https://master.php.net/note/edit/94359
Del: integrated -- https://master.php.net/note/delete/94359/integrated
Del: useless -- https://master.php.net/note/delete/94359/useless
Del: bad code -- https://master.php.net/note/delete/94359/bad+code
Del: spam -- https://master.php.net/note/delete/94359/spam
Del: non-english -- https://master.php.net/note/delete/94359/non-english
Del: in docs -- https://master.php.net/note/delete/94359/in+docs
Del: other reasons-- https://master.php.net/note/delete/94359
Reject -- https://master.php.net/note/reject/94359
Search -- https://master.php.net/manage/user-notes.php