1

How would I best go about finding duplicate key names in an array in PHP? I'm trying to validate a POST array, and realized that I need to make sure that there aren't any duplicate key names.

2 Answers 2

3

In a PHP array, the key is what identifies an element -- so, there can be no duplicate key.

Sign up to request clarification or add additional context in comments.

4 Comments

Here I am :-) Haven't been arround for a couple of months ; been back a few weeks ; not sure how long I'll stay -- but, right now, I'm here ;-)
Well, it's good to know that you still have an Internet, a computer, a browser, and a brain! :)
Thanks ^^ What I don't have enough, actually, is not internet/computer/browser -- it is time :-(
Alright, thanks, rethought the validation, so it's no longer a problem :)
2

there can't be duplicate keys (only duplicate values).

The second added value to an array with the same key will overwrite the first.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.