# Array Keys

- Thread: https://externals.io/message/5169
- Original archive: https://news-web.php.net/php.internals/5169
- Started by LingWitt@insightbb.com on 2003-11-03T13:26:03+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #5169 — LingWitt@insightbb.com — 2003-11-03T13:26:03+00:00

URL: https://externals.io/message/5169#5169

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.

---

## #5189 — LingWitt@insightbb.com — 2003-11-05T02:14:54+00:00

URL: https://externals.io/message/5169#5189 · In reply to: #5169

I don't want to seem naggish, but what do you think?



> 	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.

---

## #5190 — Andi Gutmans — 2003-11-05T06:43:54+00:00

URL: https://externals.io/message/5169#5190 · In reply to: #5169

At 09:14 PM 11/4/2003 -0500, LingWitt@insightbb.com wrote:
>I don't want to seem naggish, but what do you think?
>
>
>
> > […]

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

---

## #5191 — netcat — 2003-11-05T07:08:46+00:00

URL: https://externals.io/message/5169#5191 · In reply to: #5189

LingWitt@insightbb.com wrote:

> I don't want to seem naggish, but what do you think?
>
> 
>
> > […]
>
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 ?

> > […]
>


-- 
NetCat



--------------------------------------------------
FREE 10MB Email + Antivirus + POP3 + more...
Get it at http://www.doal.co.il:81/free/?c=antivirus

---

## #5199 — Dirkjan Ochtman — 2003-11-05T09:45:42+00:00

URL: https://externals.io/message/5169#5199 · In reply to: #5169

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...
> 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.

---

## #5277 — LingWitt@insightbb.com — 2003-11-06T01:01:10+00:00

URL: https://externals.io/message/5169#5277 · In reply to: #5191

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.



> 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 ?
