Created
June 25, 2015 20:26
-
-
Save paperdarwin/da7fc52bddeb633fb53b to your computer and use it in GitHub Desktop.
object to array
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
/* Convert object to associative array */ | |
function objectToArray( $object ) | |
{ | |
if( !is_object( $object ) && !is_array( $object ) ) | |
{ | |
return $object; | |
} | |
if( is_object( $object ) ) | |
{ | |
$object = get_object_vars( $object ); | |
} | |
return array_map( 'objectToArray', $object ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment