Re: Array element as object.
| From: | Christian Rish�j | Date: | Wed, 21 Feb 2001 07:47:59 +0000 |
| Subject: | Re: Array element as object. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-6817@lists.php.net to get a copy of this message | ||
""JJeffman"" <jjeffmanweb@conex.com.br> wrote in message
news:000701c09ba2$3b2bb020$f0d4d7c8@jjeffman...
> I've already made an object which had a property that was an array. Now I
> need to have an array that can hold objects as its elements is It possible
?
> I didn't get it the expression array[$i]->Object gave me syntax error. Any
> tips ?
$object1 = new someClass;
$object2 = new someClass;
$array = array();
$array[] = $object1;
$array[] = $object2;
The $array now contains copies of the two objects.
You can fill more in like this:
$array[] = new someClass;
Access the objects like this:
$array[0]->someMethod();
/Christian