Array Keys

php.internals

Unnamed Person

22 years ago
Now that objects are accounted for by references and id, it should be possible to use them as keys in an associative array. That might be an interesting feature to have.

Unnamed Person

22 years ago
I don't want to seem naggish, but what do you think? On 3 Nov 2003, at 8:26 AM, LingWitt@insightbb.com wrote:

netcat

22 years ago
LingWitt@insightbb.com wrote:
> I don't want to seem naggish, but what do you think? > > On 3 Nov 2003, at 8:26 AM, LingWitt@insightbb.com wrote: > >> Now that objects are accounted for by references and id, it >> should be possible to use them as keys in an associative array. That >> might be an interesting feature to have. >
Yes, nice and generally it's nice to have a language that it's possible to use anything as index but what use do you see for it ? Hash with objects as indexes ..... will hold additional data for objects? So why not store the data inside the object itself ?
>> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >
-- NetCat -------------------------------------------------- FREE 10MB Email + Antivirus + POP3 + more... Get it at http://www.doal.co.il:81/free/?c=antivirus

Unnamed Person

22 years ago
I noticed that echo $object statements in PHP 5 display object ids that are kept by the engine, so this data is already in the string form and it is data that exists. As for as a use for this feature, one can't easily say there is not a use; there have been times when I wished to have this feature --though I usually found some other way to do it, but this idea is intuitive.
> Andi Gutmans <andi@zend.com> > I don't think it's a good idea because it would break lots of other > things such as foreach(). keys have to be integers or strings.
On 5 Nov 2003, at 2:08 AM, netcat wrote:

Andi Gutmans

22 years ago
At 08:01 PM 11/5/2003 -0500, LingWitt@insightbb.com wrote:
>I noticed that echo $object statements in PHP 5 display object ids that >are kept by the engine, so this data is already in the string form and it >is data that exists. As for as a use for this feature, one can't easily >say there is not a use; there have been times when I wished to have this >feature --though I usually found some other way to do it, but this idea is >intuitive.
I didn't say there's no use but I think it's limited and can be implemented by typing adding ->key(). As mentioned in the past, the id's of objects aren't unique. They are only unique in their object group, and thus, shouldn't be used as keys. And frankly, I prefer not to expose internals to the PHP developer. Andi

Unnamed Person

22 years ago
Alright. On 6 Nov 2003, at 2:58 AM, Andi Gutmans wrote:

Andi Gutmans

22 years ago
At 09:14 PM 11/4/2003 -0500, LingWitt@insightbb.com wrote:
>I don't want to seem naggish, but what do you think? > >On 3 Nov 2003, at 8:26 AM, LingWitt@insightbb.com wrote: > >> Now that objects are accounted for by references and id, it >> should be possible to use them as keys in an associative array. That >> might be an interesting feature to have.
I don't think it's a good idea because it would break lots of other things such as foreach(). keys have to be integers or strings. I suggest you create key() methods and call those, i.e., $obj->key() Sorry, Andi

Dirkjan Ochtman

22 years ago
If you really wanted to do this you could use a serialize()d version of the object as the key. <LingWitt@insightbb.com> wrote in message news:457640B1-0E01-11D8-97C5-000393030CE6@insightbb.com...