Re: Array Question
| From: | PHP List | Date: | Mon, 28 Oct 2002 23:22:36 +0000 |
| Subject: | Re: Array Question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-121789@lists.php.net to get a copy of this message | ||
This doesn't seem to work for anything past the first key:
echo array_search(0,$myarray);
will print 'a';
None of these give me anything:
echo array_search(1,$myarray);
echo array_search("1",$myarray);
echo array_search(1,$myarray,true);
echo array_search("1",$myarray,true);
so how do I get 'd'?
> I think you are looking for array_search()
>
> On Mon, 28 Oct 2002, PHP List wrote:
>
> > Hi,
> > Lets say I have a simple array like this:
> > $myarray = array("a"=>"b","d"=>"c");
> >
> > echo $myarray[0] will return 'b';
> >
> > How can I get the name of the index? so:
> >
> > echo $myarray[something] would return 'a';
> >
> > I know I can do a list($key,$value) but I don't need to loop through the
array, I just need to be able to retrieve the key name from any point in the
array.
> >
> >
> > Thanks for any help.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>