Double associative array or indexed + associative array
- by clover
I'm undecided what's the best-practice approach for what I'm trying to do.
I'm trying to enter data into an array where the data will look like this:
apple
color: red
price: 2
orange
color: orange
price: 3
banana
color: yellow
price: 2
pineapple
color: yellow
price: 5
When I get input, let's say green apple (notice it's a combo of color + name of fruit), I'm going to check if the name of fruit part exists in the array and display its data (if it exists).
What's the right way to compose those arrays? How would I do an indexed array containing an associative array? (or would this be better as 2 nested associative arrays, I'm guessing not)