public static function getCityId($location) { if (is_object($location)) { $location = CommonUtil::object2array($location); } if (!is_array($location)) { return 0; } if ($location['cid']) { $cityId = $location["cid"]; } else { $cityId = $location["pid"]; } return $cityId; }