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

How to use php array_key_exists function

藏色散人
Release: 2023-02-22 18:26:01
Original
2604 people have browsed it

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)
Copy after login

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 "不存在!";
}
?>
Copy after login

Output:

不存在!
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template