Double associative array or indexed + associative array
I have an array
开发者_开发技巧apple
color: red
price: 2
orange
color: orange
price: 3
banana
color: yellow
price: 2
When I get input
, let's say green apple
how do I check if it exists in the array and display its data (if it exists).
$fruits = array(
'apple' => array(
'color' => 'green',
'price' => 3
),
'banana' => array(
'color' => 'yelo',
'price' => 2
),
);
That?
You can look up by name using $fruits[$fruit_name];
精彩评论