这是一款简单的php 数组 查找实例,在数组中循环输出数组所有内容,并进来判断是否是我们要找的值并输出就OK了。
$q ='www.111cn.net';
$items = array(
"great bittern"=>"botaurus stellaris",
"little grebe"=>"tachybaptus ruficollis",
"black-necked grebe"=>"podiceps教程 nigricollis",
"little bittern"=>"ixobrychus minutus",
"black-crowned night heron"=>"www.111cn.net",
"www.111cn.net"=>"ardea purpurea",
"white stork"=>"ciconia ciconia",
"spoonbill"=>"platalea leucorodia",
"red-crested pochard"=>"netta rufina",
"common eider"=>"somateria mollissima",
"red kite"=>"milvus milvus",
"hen harrier"=>"circus cyaneus",
"heuglin's gull"=>"larus heuglini"
);
foreach ($items as $key=>$value) {
if (strpos(strtolower($key), $q) !== false) {
echo "$key|$value ";
}
}
//结果为www.111cn.net|ardea purpurea