Convert an object to an array in PHP

PHP_Logo

What? The function introduced below alows you to recursively convert an object to an array. See also: Convert an array to an object in PHP The code function object_to_array($variable){ if (is_object($variable)){ $array = array(); foreach ($variable as $key=>$value){ $array[$key] = object_to_array($value); } return $array; } else{ return $variable; } }