Forum und email

array_key_exists

(PHP 4 >= 4.0.7, PHP 5)

array_key_exists — Controlla se l'indice (o chiave) specificato esiste nell'array

Descrizione

bool array_key_exists ( mixed $chiave , array $cerca )

array_key_exists() restituisce TRUE se il parametro chiave esiste nell'array. chiave può essere qualsiasi valore accettabile per un indice di array.

Example#1 esempio di array_key_exists()

<?php
$un_array 
= array("primo" => 1"secondo" => 4);
if (
array_key_exists("primo"$un_array)) {
    echo 
"L'elemento 'primo' è nell'array";
    }
    
?>

Nota: Il nome di questa funzione è key_exists() nel PHP 4.0.6.

Vedere anche isset(), array_keys() e in_array().