PHP - Fonction array_key_exists ()
Syntaxe
bool array_key_exists ( $key, $array );
Définition et utilisation
Il renvoie VRAI si le key est situé dans le array.
Paramètres
| Sr. Non | Paramètre et description |
|---|---|
| 1 |
key(Required) La clé à rechercher. |
| 2 |
array(Required) Ceci est un tableau à rechercher |
Valeurs de retour
Il renvoie TRUE si la clé donnée est définie dans le tableau sinon FALSE.
Exemple
Essayez l'exemple suivant -
<?php
$input = array('first' => 10, 'second' => 400);
if (array_key_exists('first', $input)) {
echo "The 'first' element is in the array";
}
?>
Cela produira le résultat suivant -
The 'first' element is in the array
