You are here: Re: Accessing Key=> Value Array by Index « PHP Language « IT news, forums, messages
Re: Accessing Key=> Value Array by Index

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация