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);
}