PHP Associative Array Duplicate Keys

No, you cannot have multiple of the same key in an associative array.

You could, however, have unique keys each of whose corresponding values are arrays, and those arrays have multiple elements for each key.

So instead of this…

42=>56 42=>86 42=>97 51=>64 51=>52

…you have this:

Array (
    42 => Array ( 56, 86, 97 )
    51 => Array ( 64, 52 )
)

Leave a Comment