


PHP array_key_exists implementation method to check whether the key name or index exists in the array, arraykeyexists
Jul 06, 2016 pm 02:24 PMPHP array_key_exists implementation method to check whether the key name or index exists in the array, arraykeyexists
array_key_exists()
PHP array_key_exists() function is used to check whether the given key name or index exists in the array. If it exists, it returns TRUE, otherwise it returns FALSE.
Grammar:
bool array_key_exists(mixed key, array search) parameter key is the given key name or index, which can be any value that can be used as an array index.
The array_key_exists() function also works on objects.
Example:
<?php $arr_a = array('id' => 1, 'name' => "admin"); if(array_key_exists('name', $arr_a)){ echo '键名 name 存在于数组 $arr_a 中'; } else { echo '键名 name 不存在于数组 $arr_a 中'; } ?>
The example output results are as follows:
The key name name exists in the array $arr_a. The array_key_exists() function still returns TRUE for array elements whose value is null. To check whether an array element is null, use isset().
The above implementation method of PHP array_key_exists to check whether the key name or index exists in the array is all the content shared by the editor. I hope it can give you a reference, and I hope you will support Bangkejia more.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
