Re: how to make array_search start from 0?

From: Date: Thu, 25 Apr 2002 17:21:23 +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-94591@lists.php.net to get a copy of this message
Doh! My apologies you're absolutely right. I just tested it. ------------- $search = 'bar'; //$myarray = array ('hello' => 'world', 'language' => 'php', 'foo' => 'bar'); $myarray = array ('world', 'php', 'bar'); $result = array_search($search, $myarray); echo $result; ------------- Using the associative array array_search() returns 'foo' and using the indexed array it returns '2'. So it works with both array types and does not require an array starting at index 1. Live and learn. :) -Kevin ----- Original Message ----- From: "Ford, Mike [LSS]" <M.Ford@lmu.ac.uk> To: "'Kevin Stone'" <kevin@helpelf.com>; "PHP-general" <php-general@lists.php.net> Sent: Thursday, April 25, 2002 11:12 AM Subject: RE: [PHP] how to make array_search start from 0? > > -----Original Message----- > > From: Kevin Stone [mailto:kevin@helpelf.com] > > Sent: 25 April 2002 18:02 > > > > Just looking at the manual here and it explains quite > > specifically that > > array_search() is meant to be used with associative arrays, > > not indexed > > arrays. > > No it doesn't. How on earth did you read that into it? > > Cheers! > > Mike > > --------------------------------------------------------------------- > Mike Ford, Electronic Information Services Adviser, > Learning Support Services, Learning & Information Services, > JG125, James Graham Building, Leeds Metropolitan University, > Beckett Park, LEEDS, LS6 3QS, United Kingdom > Email: m.ford@lmu.ac.uk > Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 > >

« previous php.general (#94591) next »