Created
August 27, 2012 08:53
-
-
Save sepehr/3486763 to your computer and use it in GitHub Desktop.
PHP: Recursively cast an object into array
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
<?php | |
/** | |
* Recursively casts an object into array. | |
* | |
* @param $object | |
* Object to cast to array. | |
* | |
* @return array | |
*/ | |
function object_to_array($object) | |
{ | |
return json_decode(json_encode($object), true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment