Home >Backend Development >PHP Problem >How to use php array_key_exists function

How to use php array_key_exists function

藏色散人
藏色散人Original
2019-05-25 10:04:202620browse

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.

How to use php array_key_exists function

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn