【发布时间】:2013-05-31 06:55:08
【问题描述】:
我有 assoc php 数组
0 => array
(
'categoryName' => 'Moto'
'categoryTitle' => 'Moto'
'categorySlug' => 'moto-and-tech'
'categoryAttr' => array
(
0 => 'test1'
1 => 'test2'
2 => 'test3'
3 => 'test4'
)
'categoryNested' => array
(
0 => array
(
'categoryName' => 'anything'
'categoryTitle' => 'anything'
'categorySlug' => 'anything'
'categoryAttr' => array
(
0 => 'test1'
1 => 'test1'
2 => 'test1'
3 => 'test1'
)
'categoryNested' => array()
)
1 => array
(
'categoryName' => 'any'
'categoryTitle' => 'any'
'categorySlug' => 'any'
'categoryAttr' => array
(
0 => 'test1'
1 => 'test1'
2 => 'test1'
3 => 'test1'
)
'categoryNested' => array()
)
如何通过key(catgorySlug) 搜索插入的数组,并返回所有父元素 categoryName ?
【问题讨论】:
-
你需要使用递归。
-
您应该指定结果值的格式...