personally, that's what i would do.

dealing with arrays usually makes the code a 
lot cleaner and easier to follow than using
awkward constructs like ${$C_Last}{$i}

and besides, if you ever wanted to expand your
code, you could easily pass the entire array
to a function like so:  children( $C_Last );

if you used individual variables, you could
not do that in any easy or efficient way.

> -----Original Message-----
> From: Jeff Oien [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 11, 2001 1:29 PM
> To: PHP
> Subject: FW: [PHP] Variable Next To Variable?
> 
> 
> What I'm doing is having a form page ask, "How many
> children do you want to sign up?" Then it spits out form
> fields for as many children as they asked for. So each
> field has name="C_Last_Name$x" and $x in incremented
> for each child. Should I make it name="C_Last_Name[$x]" ?
> Jeff Oien
> 
> > you should change the form field names to 
> > $Children_Last[1], $Children_Last[2]
> > instead of hardcoding $Children_Last1
> > to make iteration thru the form easier
> > and handling of the data easier...
> > 
> > you can handle it all like this:
> > 
> > $Number_Children = 5;
> > $i = $Number_Children;
> >   while ($i--) {
> >     if (! $Children_Last[$i]) {
> >     // code
> >     }
> >   }
> > 
> > > -----Original Message-----
> > > From: Jeff Oien [mailto:[EMAIL PROTECTED]]
> > > Subject: [PHP] Variable Next To Variable?
> > > 
> > > 
> > > Sorry if this has been brought up 100 times.
> > > I want to do this:
> > > 
> > > $y = "1";
> > > 
> > > while ($y <= "$Number_Children") {
> > >   if (!$C_Last_Name$y) {
> > >           error stuff;
> > >           $y++;
> > >   }
> > > }
> > > 
> > > The form submitting information to this code has field name like
> > > C_Last_Name1 C_Last_Name2 depending on how many Children
> > > are signing up for something. So I need $y to represent the number.
> > > 
> > > Hope that makes sense. Thanks for any help.
> > > Jeff Oien
> > > 
> > > -- 
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > > 
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to