php 查找数组键名并输出值

这是一款简单的php 数组 查找实例,在数组中循环输出数组所有内容,并进来判断是否是我们要找的值并输出就OK了,PHP实例代码如下:

  1. $q ='www.phpfensi.com';
  2. $items = array(
  3. "great <em>bittern</em>"=>"botaurus stellaris",
  4. "little <em>grebe</em>"=>"tachybaptus ruficollis",
  5. "black-necked grebe"=>"podiceps nigricollis",
  6. "little bittern"=>"ixobrychus minutus",
  7. "black-crowned night heron"=>"www.111cn.net",
  8. "www.111cn.net"=>"ardea purpurea",
  9. "white stork"=>"ciconia ciconia",
  10. "spoonbill"=>"platalea leucorodia",
  11. "red-crested pochard"=>"netta rufina",
  12. "common eider"=>"somateria mollissima",
  13. "red kite"=>"milvus milvus",
  14. "hen harrier"=>"circus cyaneus",
  15. "heuglin's gull"=>"larus heuglini"
  16. );
  17. foreach ($items as $key=>$value) {
  18. if (strpos(strtolower($key), $q) !== false) {
  19. echo "$key|$value ";
  20. }
  21. }
  22. //结果为www.phpfensi.com|ardea purpurea