Last active
November 11, 2015 20:36
-
-
Save kjbrum/552e93a6e9a3f90dd6b0 to your computer and use it in GitHub Desktop.
Convert an object to an 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 | |
/** | |
* Convert an object to an array. | |
* | |
* @param array $object The object to convert | |
* @return array The converted array | |
*/ | |
function object_to_array( $object ) { | |
if( !is_object( $object ) && !is_array( $object ) ) return $object; | |
return array_map( 'object_to_array', (array) $object ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment