note 101843 modified in function.json-encode by danbrown
| From: | danbrown@php.net | Date: | Thu, 13 Jan 2011 20:11:46 +0000 |
| Subject: | note 101843 modified in function.json-encode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175725@lists.php.net to get a copy of this message | ||
If you need to force an object (ex: empty array) you can also do:
<?php json_encode( (object)$arr ); ?>
which acts the same as
<?php json_encode($arr, JSON_FORCE_OBJECT); ?>
--was--
If you need to force an object (ex: empty array) you can also do:
json_encode( (object)$arr )
// which acts the same as
json_encode($arr, JSON_FORCE_OBJECT);
http://php.net/manual/en/function.json-encode.php