Ok,
I have a "form" class, which I am going to use to generate HTML forms.
I also have a form_input, which I use to generate the individual HTML
input elements.
What I want to do is some how manage the instances of the form_input
class, within the form class. There should be no problem with this, but I
can't work out how I can store an unspecified number of instances of one
class within another, is it possible to do something like this, and store
them in an array?
$input_array[] = new form_input(some vars...);
$input_array[] = new form_input(some vars...);
$input_array[] = new form_input(some vars...);
$input_array[] = new form_input(some vars...);
then when I want to do stuff with the individual form elements I can do:
$input_array[1]->do_some_functi on();
$input_array[2]->do_some_functi on();
Or more likely what I would like to do, is use a foreach loop.
Has anyone done something like this before, and can offer tips?
Many Thanks,
Harry
I have a "form" class, which I am going to use to generate HTML forms.
I also have a form_input, which I use to generate the individual HTML
input elements.
What I want to do is some how manage the instances of the form_input
class, within the form class. There should be no problem with this, but I
can't work out how I can store an unspecified number of instances of one
class within another, is it possible to do something like this, and store
them in an array?
$input_array[] = new form_input(some vars...);
$input_array[] = new form_input(some vars...);
$input_array[] = new form_input(some vars...);
$input_array[] = new form_input(some vars...);
then when I want to do stuff with the individual form elements I can do:
$input_array[1]->do_some_functi on();
$input_array[2]->do_some_functi on();
Or more likely what I would like to do, is use a foreach loop.
Has anyone done something like this before, and can offer tips?
Many Thanks,
Harry
Comment