Re: object references?
| From: | Ignacio Vazquez-Abrams | Date: | Thu, 16 Nov 2000 16:28:02 +0000 |
| Subject: | Re: object references? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-25716@lists.php.net to get a copy of this message | ||
On Thu, 16 Nov 2000, Mailing List Mailbox wrote:
> I have a bunch of objects embedded such as makes sense for what I'm
> doing..
>
> 1 {
> 2 {
> 3 {}
> 4 {}
> }
> 5 {}
> }
>
> or something like that. But I also need to keep an array of names = object
> for them. Is there a way to do this so that I can just register each
> object via a function something like reg_obj ( $my_obj ) and that
> functions references that object w/ a name into an array?
>
How about:
$arr=Array(
"obj1" => &$obj1,
"obj2" => &$obj2,
...
);
or failing that:
$arr=Array();
$arr["obj1"]=&$obj1;
...
IIRC, to refer to them you'd have to do this:
$o=$arr["obj1"];
$o->method();
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>