note 94359 deleted from function.json-encode by cmb
| From: | cmb@php.net | Date: | Tue, 05 Nov 2019 14:30:19 +0000 |
| Subject: | note 94359 deleted from function.json-encode by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212931@lists.php.net to get a copy of this message | ||
Note Submitter: rlz_ar at yahoo dot com
----
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 );
?>