Re: how to make array_search start from 0?

From: Date: Thu, 25 Apr 2002 16:54:00 +0000
Subject: Re: how to make array_search start from 0?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-94580@lists.php.net to get a copy of this message
On Friday 26 April 2002 00:30, andy wrote: > Hi there, > > I am passing an array through the URL with a ',' inbetween: > var=php,mysql,super > Parsing is done with: explode (',',$var). This gives me an array starting > with 0 > > Later on I have to search for lets say php with array_search. > > Unfortunatelly array_search requires an array starting with 1. So php is > not found. Haven't used this function before, but where does it say anything about requiring an array starting with 1? Did you try it anyway? > Does anybody know a workaround for this? You can do: $my_array = array_flip($my_array) $key = $my_array['search_item']; -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* "Conversion, fastidious Goddess, loves blood better than brick, and feasts most subtly on the human will." -- Virginia Woolf, "Mrs. Dalloway" */

« previous php.general (#94580) next »