Skip to content

Instantly share code, notes, and snippets.

@sepehr
Created August 27, 2012 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sepehr/3486763 to your computer and use it in GitHub Desktop.
Save sepehr/3486763 to your computer and use it in GitHub Desktop.
PHP: Recursively cast an object into array
<?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