Re: array_search() problem

From: Date: Thu, 12 Sep 2002 21:56:38 +0000
Subject: Re: array_search() problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-116218@lists.php.net to get a copy of this message
> What I was looking for was finding out what was the index of thet > value, lets say I have a array with some values like (23, 56, 45, 47) > and i don't know where the walue I'm looking for is indexed in the array > and I want to find out what the indexnumber is, how would that be > possable <? function array_index($array,$needle) { /* written by bas@startpunt.cc */ foreach($array as $key=>$value) if($value==$needle) return $key; return -1; } $array=array(23, 56, 45, 47); echo array_index($array,45); echo array_index($array,48); if(array_index($array,48)<0)echo 'not found'; else echo 'found'; ?>

« previous php.general (#116218) next »