我想从php中的多维数组中获取三个键
例如:
[
[0]=>[
'name' => 'appetizers',
'category' => 'category1',
'price' => 20,
'desc' => 'best in it\'s category',
'brand' => 'abc'
],
[1]=>[
'name' => 'appetizers',
'category' => 'category2',
'price' => 30,
'desc' => 'best in it\'s category',
'brand' => 'abc2'
]
]
我想要的键是name
,price
和desc
我可以使用循环来做到这一点,但是我很好奇是否有像array_column这样的函数,因为它为索引提供了单列。
我想要的输出有点像这样:
[
[0]=>[
'name' => 'appetizers',
'price' => 20,
'desc' => 'best in it\'s category'
],
[1]=>[
'name' => 'appetizers',
'price' => 30,
'desc' => 'best in it\'s category',
]
]
OR this can also be beneficial
[
[0]=>[
'appetizers',
20,
'best in it\'s category'
],
[1]=>[
'appetizers',
30,
'best in it\'s category',
]
]