|
Posted by blackberryoctopus on 01/11/07 22:37
Geoff Berrow wrote:
> Message-ID: <1168533804.991748.11600@i56g2000hsf.googlegroups.com> from
> ZeldorBlat contained the following:
>
> >> The data coming in is named as follows data1, data2, data3, ... data40.
> >> So I need the php variables to be named in the same way. Whats the
> >> syntax here? Thanks for any help.
> >
> >Data coming in from where? GET? POST? Command line? Cookies? Let's
> >suppose it's POST and you have POST variables named data1, data2, ...
> >data40. Then it would be something like this:
> >
> >for($i = 1; $i <= 40; $i++) {
> > $name = "data$i";
> > $$name = $_POST[$name];
> >}
> Or you could use extract
>
> extract($_POST);
>
> Or you could just use the array elements directly
>
> echo $_POST['data1'];
> --
> Geoff Berrow (put thecat out to email)
> It's only Usenet, no one dies.
> My opinions, not the committee's, mine.
> Simple RFDs http://www.ckdog.co.uk/rfdmaker/
I know that referencing the elements directly would work, but it would
be cumbersome and in flexible for future revisions. I am trying to
avoid this; so some sort of for loop to populate an array or multiple
variables in php seemed like the best way.
Navigation:
[Reply to this message]
|