$Fields = new EditField;
$Fields->Name = $result_array['Field'];
</pre>
Later on in the same while loop I have this (I added it as a test)
<pre>
echo $Fields->Name;
echo "< BR >";
echo $Fields->Hidden;
echo "< BR >";
echo $Fields->Type;
echo "< BR >";
</pre>
Hidden and Type are both other variables in the class. This echo's out all the data correctly. Now later on in the script (that lot was before the <HTML> tag this next bit is in the <BODY></body> tags) I have this
<pre>
for($i = 0;$i < $ArraySize;$i++)
{
printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>", $Fields[$i]->Type, $Fields[$i]->Name, $Fields[$i]->Hidden);
}
</pre>
$ArraySize is set correctly and everything but for some $Fields[$i]->Type, $Fields[$i]->Name and $Fields[$i]->Hidden all have nothing in them. Can anyone tell me what's going wrong here? </i>
[edit]Fixed < br > formatting (in the real code there aren't any spaces in the tag[/edit]
<SPAN CLASS=editedby>[edited by - Monder on May 7, 2003 6:59:33 PM]</SPAN>
Arrays of Classes in PHP
Can someone please explain how you can create an array of classes in PHP? I have a while loop that should add a class with data in it into an array every iteration. The way I add stuff into the array is this
I've just realised that I should be using
and
But when I do that the array still doesn't get filled. I must be doing something wrong. Can someone tell me what it is?
[edited by - Monder on May 8, 2003 1:36:55 PM]
$Fields = new EditField;$Fields[$i]->Name = $result_array['Field'];
and
echo $Fields[$i]->Name;echo "< BR >";echo $Fields[$i]->Hidden;echo "< BR >";echo $Fields[$i]->Type;echo "< BR >";
But when I do that the array still doesn't get filled. I must be doing something wrong. Can someone tell me what it is?
[edited by - Monder on May 8, 2003 1:36:55 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement