如何在php中实现resource => value storage [duplicate]

This question already has an answer here:

If you try to create an associative array with a resource id as the key, for example, you get a warning about "Strict standards" , and the resource is "cast to interger". How would one then link two values in an associative way? Is it possible in an array?

</div>

Not possible..The keys in an array can be either be a string or an integer.

Taken from PHP Manual..

  • Strings containing valid integers will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.
  • Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.
  • Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0.
  • Null will be cast to the empty string, i.e. the key null will actually be stored under "".
  • Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.

Source