此函数同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? "; 5 echo "The result of the isset() function : " .( isset($arr['key']) ? 1 : 0 )." "; 6 echo "The result of the key_exists() function :" .key_exists('key',$arr) ." "; 7 echo "It's a big problem! The isset() function is faster than the key_exists() function. "; 8 echo "So you can use the snip code : "; 9 10 if(isset($arr['key']) || key_exists('key',$arr)){ 11 echo "'Key' is exist in arr array! "; 12 }
例子二: