Created
July 17, 2019 16:37
-
-
Save phpfiddle/a361ab9fb2375e160ea2abcaa0b051c6 to your computer and use it in GitHub Desktop.
[ Posted by Tommie C ] Convert PHP object to array using JSON methods
This file contains 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
<?php | |
$nested_object = new stdClass; | |
$nested_object->apple = "apple value"; | |
$nested_object->orange = "orange value"; | |
$nested_object->grape = "grape value"; | |
$nested_object->pear = "pear value"; | |
$array = json_decode(json_encode($nested_object), true); | |
var_dump($nested_object, "object converted to array using json methods" , $array); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment