|
Posted by Bob Johnson on 10/16/00 11:17
In article <d7h5ou$977$1@garrison.globalnet.hr>, Berislav Lopac
<berislav.lopac@lopsica.com> wrote:
> Bob Johnson wrote:
> > I hope this is a silly questions (been programming for 4 days
> > straight)...
> >
> > Given an array:
> > $foo = array(one=>11,two=>22,tree=>33);
> >
> > $fum = $foo[0];
> >
> > $fum returns null. There are cases where I won't know the name "one"
> > and still need to access by Index.
>
> You can try this:
>
> $keys = array_keys($foo);
> $fum = $foo[$keys[0]];
>
> Berislav
Many thanks - that's perfect. I resorted to using current(), next(),
and prev(). This is much cleaner
Berislav - appreciate your post!
Navigation:
[Reply to this message]
|