這裏我使用的代碼適用於所有其他輸入,但不適用於hospital
爲什麼?爲什麼preg_match()在某些情況下不匹配
如果你建議任何其他過濾器,那麼這將是非常感激。
這裏是我的代碼:
$type = strtolower("hospital");
if(preg_match('/it|IT|it services|it service|it infrastructure|it infrastructures/',$type)){
$img = "images/it1-200x111.jpg";
}else if(preg_match('/business|business solutions|biz solutions|business solution|biz solution/',$type)){
$img = "images/business-200x111.jpg";
}else if(preg_match('/manpower|manpower solution|manpower solutions|manpower services|manpower service|human resource|human resources/',$type)){
$img = "images/mp-1-200x111.jpg";
}else if(preg_match('/financial|finance|financial solution|financial solutions|financial service|financial services/',$type)){
$img = "images/fin-200x111.jpg";
}else if(preg_match('/marketing|marketing solution|marketing solutions|marketing service|marketing services/',$type)){
$img = "images/mark1-200x111.jpg";
}else if(preg_match('/real estate|real estates|real estate solution|real estates solution|real estate solutions/',$type)){
$img = "images/real1-200x111.jpg";
}else if(preg_match('/school|schooling services|school services|schools service|schooling service/',$type)){
$img = "images/school1-200x111.jpg";
}else if(preg_match('/college|college service|college services|colleges/',$type)){
$img ="images/coll1-200x111.jpg";
}else if(preg_match('/hospital|hospitals|hospital service|hospital services/',$type)){
$img = "images/hosp-1-200x111.jpg";
}else{
$img = "images/it1-200x111.jpg";
}
echo $img;
你的意思是醫院將在網址..它不工作..? –
,因爲''it' on''' – jamesjaya
$ type確定要輸入的條件,但不輸入醫院區域,其他輸入 – EaBangalore