$city _str=fopen (Cgi_path.) /data/weather/city.dat "," R ");
$city _ch=fread ($city _str,filesize (Cgi_path.) /data/weather/city.dat "));
$city _ch_arr=explode ("|"), $city _ch);
If you can match the location to the city
if (Strstr ($area _ga, "City")) {
foreach ($city _ch_arr as $city _ch_arr_item) {
if (@strstr ($area _ga, $city _ch_arr_item)) {
echo $area _ga. ' <br> ';
echo $city _ch_arr_item;
$s _city= $city _ch_arr_item;
}
}
}//If you can't find the city, then see if you can find a province. Sometimes there is such a situation: The Great Wall of Guangdong province, such as broadband to belong to the provincial capitals
ElseIf (Strstr ($area _ga, "Hebei")!==false) {
$s _city= "Shijiazhuang";
}elseif (Strstr ($area _ga, "Fujian")!==false) {
$s _city= "Fuzhou";
}elseif (Strstr ($area _ga, "Taiwan")!==false) {
$s _city= "Taipei";
}elseif (Strstr ($area _ga, "Hong Kong")!==false) {
$s _city= "Hong Kong";
}elseif (Strstr ($area _ga, "Guangxi")!==false) {
$s _city= "nanning";
}elseif (Strstr ($area _ga, "Zhejiang")!==false) {
$s _city= "Hangzhou";
}elseif (Strstr ($area _ga, "Jiangsu")!==false) {
$s _city= "Nanjing";
}elseif (Strstr ($area _ga, "Shandong")!==false) {
$s _city= "Jinan";
}elseif (Strstr ($area _ga, "Anhui")!==false) {
$s _city= "Hefei";
}elseif (Strstr ($area _ga, "Hunan")!==false) {
$s _city= "Changsha";
}elseif (Strstr ($area _ga, "Sichuan")!==false) {
$s _city= "Chengdu";
}elseif (Strstr ($area _ga, "Yunnan")!==false) {
$s _city= "Kunming";
}elseif (Strstr ($area _ga, "Guangdong")!==false) {
$s _city= "Guangzhou";
}elseif (Strstr ($area _ga, "Guizhou")!==false) {
$s _city= "Guiyang";
}elseif (Strstr ($area _ga, "Tibet")!==false) {
$s _city= "Lhasa";
}elseif (Strstr ($area _ga, "Xinjiang")!==false) {
$s _city= "Urumqi";
}elseif (Strstr ($area _ga, "Mongolia")!==false) {
$s _city= "hohhot";
}elseif (Strstr ($area _ga, "Heilongjiang")!==false) {
$s _city= "Harbin";
}elseif (Strstr ($area _ga, "Liaoning")!==false) {
$s _city= "Shenyang";
}elseif (Strstr ($area _ga, "Jilin")!==false) {
$s _city= "Changchun";
}elseif (Strstr ($area _ga, "Henan")!==false) {
$s _city= "Zhengzhou";
}elseif (Strstr ($area _ga, "Hubei")!==false) {
$s _city= "Wuhan";
}elseif (Strstr ($area _ga, "Shanxi")!==false) {
$s _city= "Taiyuan";
}elseif (Strstr ($area _ga, "Shaanxi")!==false) {
$s _city= "Xi ' an";
}elseif (Strstr ($area _ga, "Gansu")!==false) {
$s _city= "Lanzhou";
}elseif (Strstr ($area _ga, "Ningxia")!==false) {
$s _city= "Yinchuan";
}elseif (Strstr ($area _ga, "Hainan")!==false) {
$s _city= "Haikou";
}elseif (Strstr ($area _ga, "Jiangxi")!==false) {
$s _city= "Nanchang";
}elseif (Strstr ($area _ga, "Macau")!==false) {
$s _city= "Macao";
}
If none exists, the default display is Guangzhou, such as Local machine.
else{
$s _city= "Guangzhou";
}
As above code:
Where City.dat are some of the city formats are like this
guangzhou | shenzhen | shantou | huizhou | zhuhai | jieyang | foshan | heyuan | Yangjiang | maoming | zhanjiang | Meizhou | zhaoqing | shaoguan | chaozhou | dongguan | zhongshan | qingyuan | jiangmen | Shanwei | Yunfu | Zengcheng | conghua | Lechang | Nanxiong | taishan | Kaiping | heshan | enping | Lianjiang | Leizhou | Wuchuan | Gaozhou | Huazhou | gaoyao | sihui | xingning | Lufeng | yangchun | china | germany | |--puning City | beijing | tianjin | shanghai | chongqing | urumqi | karamay | shihezi | alar | Tumshuk | five Hami | turpan | Yining | Tacheng | altay | Kuitun | Bole | changji | Fukang | korla | Atushi | ursula | lhasa Shigatse | yinchuan | shizuishan | wuzhong | guyuan | zhongwei | hohhot | baotou | Wuhai | chifeng | tongliao | ordos | hulunbeier | Bayan nur | wulanchabu | Huolinguolei | Yakeshi | Zalantun | Genhe |
Reference
echo strstr (' AAAAAAAAAAABOAAAAAAAAAAAABOXCCCCCCCCCBCCCCCCCCCCCCCC ', ' box '). " n ";
05//Full matching box in the middle does not stop at the front and b
echo strstr (' aaaaaaabaaa aaaa aaaaaaaaaboxccccccccccccboxccccccccccc ', ' box '). " n ";
07//There are two keywords when the first stop is encountered.
The Echo strstr (' Subscrtibe We to free newsletter about the New freew to ' and ' to '). " n ";
09
it.