function objectToArray( $object ){
$temp = is_object ( $object ) ? get_object_vars( $object ) : $object ;
$arr = array ();
foreach ( $temp as $k => $v ) {
$v = ( is_array ( $v ) || is_object ( $v )) ? $this->objectToArray( $v ) : $v ;
$arr [ $k ] = $v ;
}
return $arr ;
}