<?php
function object2array($object)
{
    if (is_object($object)) {
        foreach ($object&nbsp;as&nbsp;$key => $value) {
            $array[$key] = $value;
        }
    } else {
        $array&nbsp;=&nbsp;$object;
    }
    return $array;
}
?>