Re: Using Array of classes as a class member variable?
| From: | Papp Gyozo | Date: | Thu, 04 Oct 2001 16:19:29 +0000 |
| Subject: | Re: Using Array of classes as a class member variable? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69949@lists.php.net to get a copy of this message | ||
> First some basic questions:
> (1) Can you create an unitialised array ?
do you mean:
$array = array(); // creates an empty array;
> (2) Can an unitinialised array be a class member variable ?
for( $i = 0 ; $i < 5; $i++)
$array[] =& new User();
I think it should work.
>
> I have a class called "user" - which represents one row in a mySQL table
> (also called user)
>
> I want to create a class called "userBag" - this class will contain an
> array of "user" classes - the constructor for "userBag" gets an SQL
> statement and uses this do decide which users to place in the userBag
>
> Maybe I'm going about this all worng, but is there some other way I can
> store a variable number of classes (Such as a CObject class in MFC for
> Visual C++) - i.e. is there soem other collection class/type I don't know
> of ?
>
> Thanks,
>
> Martin.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>