首页 > Web开发 > 详细

PHP key_exists

时间:2017-06-17 09:35:57      阅读:317      评论:0      收藏:0      [点我收藏+]

此函数同array_key_exsits().

1.函数的作用:判断一个数组是否含有某个键值

2.函数的参数:

  @param string  $key

  @param array $haystack

3.

例子一:

 1 <?php
 2 $arr = [‘key‘ => null];
 3 
 4 echo "To check whether key exist?\n";
 5 echo "The result of the isset() function : " .( isset($arr[‘key‘]) ? 1 : 0 )."\n";
 6 echo "The result of the key_exists() function :" .key_exists(‘key‘,$arr) ."\n";
 7 echo "It‘s a big problem! The isset() function is faster than the key_exists() function.\n";
 8 echo "So you can use the snip code :\n";
 9 
10 if(isset($arr[‘key‘]) || key_exists(‘key‘,$arr)){
11     echo "‘Key‘ is exist in arr array!\n";
12 }

例子二:

 

PHP key_exists

原文:http://www.cnblogs.com/jingjingdidunhe/p/7030162.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!