For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > February 2005 > build variable name in a loop









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author build variable name in a loop
Steve Greenaway

2005-02-16, 8:57 am

I have to process a form that sends many text fields. The names of
these fields are just numbered, ie: cd1, cd2, cd3, etc up to 30.

Using while($x<=30) {... how do I connect $x to a cd prefix to get a
complete variable name?
Jeppe Uhd

2005-02-16, 8:57 am

Steve Greenaway wrote:
> I have to process a form that sends many text fields. The names of
> these fields are just numbered, ie: cd1, cd2, cd3, etc up to 30.
>
> Using while($x<=30) {... how do I connect $x to a cd prefix to get a
> complete variable name?


${'cd'.$x}

--
MVH Jeppe Uhd - NX http://nx.dk
Webhosting for nørder og andet godtfolk


Steve Greenaway

2005-02-16, 3:57 pm

Jeppe Uhd wrote:
> Steve Greenaway wrote:
>
>
>
> ${'cd'.$x}
>

Simpler than I thought. Thanks.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com