Reply to Re: referencing an array element with a string variable

Your name:

Reply:


Posted by Bosconian on 07/20/05 04:26

"Ken Robinson" <kenrbnsn@rbnsn.com> wrote in message
news:1121746343.422353.202300@g47g2000cwa.googlegroups.com...
>
>
> Bosconian wrote:
> > I've been researching this for hours and can't seem to find the right
> > syntax.
> >
> > I need to retrieve a value of an array by referencing the element using
a
> > string variable.
> >
> > For example:
> >
> > $data['lastname'] = 'hank';
> > $element = 'lastname';
> > echo $data[$element];
> >
> > Outputs:
> >
> > hank
> >
> > Seems straightforward enough, but the solution escapes me.
>
> That should work fine. What problems are you encountering? What are you
> trying to do?
>
> Ken
>

Thanks to all who responded.

Turns out the syntax was correct (as noted.) My array was in fact not being
defined correctly so the element was therefore empty.

Sorry for wasting your time.

[Back to original 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

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