note 119951 deleted from function.json-decode by salathe

From: Date: Mon, 21 Sep 2020 14:59:48 +0000
Subject: note 119951 deleted from function.json-decode by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215411@lists.php.net to get a copy of this message
Note Submitter: Patanjali ---- A recursive function to convert a decoded JSON object into a nested array. <?php function to_array(&$object=''){ // IF OBJECT, MAKE ARRAY if(is_object($object)){$object = (array)$object;} // IF NOT ARRAY OR EMPTY ARRAY, RETURN = LEAVES SCALARS if(!is_array($object)||empty($object)){return;} // FOR EACH ITEM, RECURSE VALUE foreach($object as &$Value){to_array($Value);} } ?> <?php // MAKE INTO ARRAY $Object=json_decode($Json); to_array($Object); ?>

« previous php.notes (#215411) next »