function array_filter_by_key($key_values, $filter_keys) { if (empty($key_values)) { return array(); } $result = array(); array_merge_by_key($key_values, $result, $filter_keys); return $result; }
function parse_rent_house_item($CI, $house) { if (!isset($house) || empty($house) || !is_array($house)) { return $house; } $new_house = array(); $new_house['hid'] = $house['hid']; $new_house['title'] = parse_get_by_key($CI, $house, 'title'); $new_house['images'] = parse_get_by_key($CI, $house, 'images', ''); $new_house['area'] = parse_from_attr_array($CI, $house, 'aid', 'areas', 'area_name'); $new_house['community'] = parse_house_community($CI, $house); $new_house['subinfo_area'] = parse_house_area_community($CI, $house); $new_house['price'] = parse_get_by_key($CI, $house, 'price'); $new_house['room_type'] = to_room_type($house); $new_house['size'] = parse_get_by_key($CI, $house, 'size'); $new_house['floors'] = parse_house_floors($CI, $house); $new_house['floors_total'] = parse_house_floors_total($CI, $house); $new_house['subinfo_floors'] = parse_house_floor($CI, $house); $new_house['rent_type'] = parse_from_array($CI, $house, 'rent_type', 'rent_types'); $new_house['rentpay_type'] = parse_from_array($CI, $house, 'rentpay_type', 'rentpay_types'); $new_house['house_type'] = parse_from_array($CI, $house, 'house_type', 'house_types'); $new_house['decor'] = parse_from_array($CI, $house, 'decor', 'house_decors'); $new_house['orientation'] = parse_from_array($CI, $house, 'orientation', 'house_orientations'); $new_house['details'] = parse_get_by_key($CI, $house, 'details'); $new_house['update_time'] = parse_get_by_key($CI, $house, 'update_time'); // poster 信息 $poster = array(); array_merge_by_key($house, $poster, array('uid', 'user_name', 'true_name', 'sex', 'contact_tel', 'contact_mobile', 'qqchat', 'wechat', 'email', 'avatar')); $new_house['poster'] = $poster; return $new_house; }