Skip to content

Instantly share code, notes, and snippets.

@paperdarwin
Created June 25, 2015 20:26
Show Gist options
  • Save paperdarwin/da7fc52bddeb633fb53b to your computer and use it in GitHub Desktop.
Save paperdarwin/da7fc52bddeb633fb53b to your computer and use it in GitHub Desktop.
object to array
/* 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