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]
|