Skip to content

Instantly share code, notes, and snippets.

@assertchris
Created June 1, 2010 12:53
Show Gist options
  • Save assertchris/420913 to your computer and use it in GitHub Desktop.
Save assertchris/420913 to your computer and use it in GitHub Desktop.
PHP object->array method
function toArray($result)
{
$array = array();
foreach ($result as $key => $value)
{
if (is_object($value))
{
$array[$key] = toArray($value);
}
else if (is_array($value))
{
$array[$key] = toArray($value);
}
else
{
$array[$key] = $value;
}
}
return $array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment