码迷,mamicode.com
首页 > Web开发 > 详细

PHP key_exists

时间:2017-06-17 10:08:53      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:个数   作用   isset   tac   exists   function   sni   param   its   

此函数同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

标签:个数   作用   isset   tac   exists   function   sni   param   its   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!