I am creating a class that will build a form. So far it has been pretty simple. But now, I have run into a big problem I cannot solve.
I have a class called "fields".
I have another class called "formBuilder"
The "fields" class takes several arguments in its constructor to build the object.
The "formBuilder" Class takes several arguments, including an array of "fields" objects.
Now the "formBuilder" Class has a function (which is the source of my problems) that will print out the form itself using the array of field objects.
My question is this -
If I have an array of objects, how on earth can I get those objects out? I have a foreach loop, but nothing I do seems to work. Mainly due to the "fields" constructor requiring a set of parameters, so I cannot simply do this -
foreach($objArray AS $value)
{
$thisFieldHere = new fields;
}
This will produce an error stating that the constructor is missing arguments. I have tried to just assign the obj to a variable name and then spit out, but that does not work either.
I know that in Java I have a convert function I run to convert a datatype to another datatype. I am sure that PHP when putting the object in the array converts it to a standard object type. How do I convert it to a type of "fields"?
Thanks