Created
June 1, 2019 23:34
-
-
Save rolldone/b92e85142fea0c7ba678acc054646ecd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public 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) {$this->to_array($Value);} | |
} | |
/** | |
--------------------------------------------- | |
How to use ? | |
------------------ **/ | |
$test = json_decode($stringJSON); | |
/** Dont new initalize beginning just keep $test to converted **/ | |
to_array($test); | |
dd($test); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment