开发者

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];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜