Home > Article > Backend Development > How to use php array_key_exists function
php The array_key_exists function is used to check whether the specified key name exists in an array. Its syntax is array_key_exists(key,array). The parameter key is required and refers to the specified key name. array is required and refers to the specified array.
php How to use the array_key_exists function?
Function: Check whether the specified key name exists in an array
Syntax:
array_key_exists(key,array)
Parameters:
key required. Specifies the key name.
array Required. Specifies an array.
Description: Returns true if the key name exists, and returns false if the key name does not exist.
php array_key_exists() function usage example
<?php $a=array("php中文网"=>"西门大官人","php中文网"=>"灭绝师太"); if (array_key_exists("phpStudy",$a)) { echo "存在!"; } else { echo "不存在!"; } ?>
Output:
不存在!
The above is the detailed content of How to use php array_key_exists function. For more information, please follow other related articles on the PHP Chinese website!