Re: note 33202 added to function.array-key-exists

From: Date: Thu, 19 Jun 2003 04:07:31 +0000
Subject: Re: note 33202 added to function.array-key-exists
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-50615@lists.php.net to get a copy of this message
On Wed, 2003-06-18 at 19:58, marco777@bol.com.br wrote: > If you have an array with 2 indexes, you need to do a double test with the array_key_exists: > > $MyArray = array("f1" => array("i1", "i2", "i3"), > "f2" => array("i1", "i2", "i3")) > > if(array_key_exists("f1", $MyArray) //return true > if(array_key_exists("i1", $MyArray["f1"]) //return true > print("The pair key ["f1"]["i1"] exist in $MyArray"); Hi there, There is an easier way to do this: if (isset($MyArray['f1']['i1'])) { echo "Key exists\n"; } Cheers, Torben -- Torben Wilson <torben@php.net> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----

« previous php.notes (#50615) next »