我有一个这样的数组
$category = [
'cat1' => [
'images/category/cat1/icon1.jpg',
'images/category/cat1/icon2.jpg',
'images/category/cat1/icon3.jpg',
],
'cat2' => [
'images/category/cat2/icon1.jpg',
'images/category/cat2/icon2.jpg',
'images/category/cat2/icon3.jpg',
]
];
我想得到这样的数组
$categories = [
'images/category/cat1/icon1.jpg',
'images/category/cat1/icon2.jpg',
'images/category/cat1/icon3.jpg',
'images/category/cat2/icon1.jpg',
'images/category/cat2/icon2.jpg',
'images/category/cat2/icon3.jpg',
];
我试过了,但没有得到预期的输出。
$categories = array_map(function($cat){return $cat;},$category);