Maison  >  Article  >  développement back-end  >  php-Arrays函数-array_key_exists-检查给定的键名或索引是否存在于数组中_PHP教程

php-Arrays函数-array_key_exists-检查给定的键名或索引是否存在于数组中_PHP教程

WBOY
WBOYoriginal
2016-07-13 17:51:00693parcourir

array_key_exists() 检查给定的键名或索引是否存在于数组中

【功能】
         该函数将返回一个布尔型值,
         如果指定的key存在于指定的数组中则返回true,否则返回false
         同时该函数也可以用于对象,即检查指定的key是否在于对象中
【使用范围】
         php4>4.1.0、php5.
【使用】
         bool array_key_exists(mixed key,array search)
         key/必需/键名
         search/必需/查找的数组
【示例】
[php]
$search_array = array('first'=>1,'second'=>4); 
if(array_key_exists('first',$search_array)){ 
        echo "The 'first' element is in the array"; 

/*
The 'first' element is in the array
*/ 

 

摘自 zuodefeng的笔记

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478212.htmlTechArticlearray_key_exists() 检查给定的键名或索引是否存在于数组中 【功能】 该函数将返回一个布尔型值, 如果指定的key存在于指定的数组中则返回...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn