Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8969539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:36:24+00:00 2026-06-15T17:36:24+00:00

The PHP documentation states: Arrays and objects can not be used as keys .

  • 0

The PHP documentation states:

Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.

AFAIK, PHP arrays are ordered hash-maps. So, why is it per se forbidden to use objects as keys, is there a reason for this limitation? Why is there no possibility to implement a hash function in a class in order to use it as a key?

On a related note, is there a PHP implementation of a hash-map which solves this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:36:25+00:00Added an answer on June 15, 2026 at 5:36 pm

    Keys need to be immutable in order for them to work. If your objects are mutable, then they can’t be keys. That’s true in every language that implements them: Java, C#, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The PHP documentation states that php://input can only be read once. In my application
The PHP documentation is not very explicit and only states that: SplObjectStorage::offsetExists Checks whether
In the PHP Constructors and Destructors documentation it states Note: Parent constructors are not
The documentation here is not very clear: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing&s[]=editurl#saverow Do I have to manually make
Constructor for PHP's exception has third parameter, documentation says: $previous: The previous exception used
According to the PDO documentation , you can store database login details in php.ini,
I need to get the basics of this function. The php.net documentation states, for
Official PHP documentation states that filter_var_array() supports array filtering in the following format: $data
PHP's documentation for the proc_open function states that when spawning a child process, you
The PHP documentation says the following about the __call() magic method: __call() is triggered

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.