Skip to content

Instantly share code, notes, and snippets.

@Naatan
Created November 11, 2011 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Naatan/1359197 to your computer and use it in GitHub Desktop.
Save Naatan/1359197 to your computer and use it in GitHub Desktop.
Converts objects to array, recursively
function object_to_array($ob)
{
if (!is_array($ob) AND !is_object($ob))
{
return $ob;
}
$ob = (array) $ob;
foreach ($ob AS $k => $v)
{
$ob[$k] = object_to_array($ob[$k]);
}
return $ob;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment