answersLogoWhite

0

A key is the name of a variable in an array ($array["key"]) and the index is the position it's at ($array = ["key" => 0], the index would be 0).

Keys and indices are the same if the array is not associative though ($array = [true], the key holding the value true is named 0 and is at index 0).

User Avatar

Wiki User

8y ago

Still curious? Ask our experts.

Chat with our AI personalities

JudyJudy
Simplicity is my specialty.
Chat with Judy
RossRoss
Every question is just a happy little opportunity.
Chat with Ross
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi

Add your answer:

Earn +20 pts
Q: What is difference between key and index in php arrays?
Write your answer...
Submit
Still have questions?
magnify glass
imp