English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The PHP array_key_exists() function checks if there is a specified key name or index in the array
bool array_key_exists ($key, $array);
When the key key exists in the array ($array), array_key_exists() returns TRUE.
Serial Number | Parameters and Description |
---|---|
1 | key(Required) The key to be searched for. |
2 | array(Required) This is the array to be searched |
If the given key exists in the array, it returns TRUE, otherwise it returns FALSE.
Check if the specified key name exists in the array
<?php $input = array('first' => 10, 'second' => 400); if (array_key_exists('first', $input)) { echo "The first element exists in the array"; } ?>Test and see‹/›
Output result:
The first element exists in the array