[英]PHP loop through array and split into seperate arrays
Hi I have this PHP array of Amazon Sub Categories what I am trying to do is loop through the array and split into 3 seperate ones, 嗨,我有这个PHP的Amazon Sub Categories数组,我想做的是遍历该数组并分成3个单独的数组,
Heres the Array, and needs to be split into 3 arrays $request, and all the children under it $subCats and final variable $Ancestors. 这里是数组,需要分成3个数组$ request和它下面的所有子元素$ subCats和最终变量$ Ancestors。 The $subCats will contain all the [Children][BrowseNode].
$ subCats将包含所有的[Children] [BrowseNode]。 Its driving me mad I cant seem to loop through correctly.
它让我发疯,我似乎无法正确地通过。
Any thoughts people. 任何想法的人。 Cheers in advanced.
欢呼雀跃。
J. J.
Array
(
[Request] => Array
(
[IsValid] => True
[BrowseNodeLookupRequest] => Array
(
[BrowseNodeId] => 66471031
[ResponseGroup] => Array
(
[0] => BrowseNodeInfo
)
)
)
[BrowseNode] => Array
(
[BrowseNodeId] => 66471031
[Name] => Beauty
[Children] => Array
(
[BrowseNode] => Array
(
[0] => Array
(
[BrowseNodeId] => 118423031
[Name] => Cosmetics
)
[1] => Array
(
[BrowseNodeId] => 74006031
[Name] => Cosmetics_hidden
)
[2] => Array
(
[BrowseNodeId] => 118457031
[Name] => Fragrances
)
[3] => Array
(
[BrowseNodeId] => 66466031
[Name] => Fragrances_hidden
)
)
)
[Ancestors] => Array
(
[BrowseNode] => Array
(
[BrowseNodeId] => 66280031
[Name] => Categories
[IsCategoryRoot] => 1
[Ancestors] => Array
(
[BrowseNode] => Array
(
[BrowseNodeId] => 65801031
[Name] => Health & Beauty
)
)
)
)
)
)
This should do it: 应该这样做:
$request = your_main_array['request'];
$subCats = your_main_array['BrowseNode']['Children']['BrowseNode'];
$Ancestors = your_main_array['BrowseNode']['Ancestors']
['Children']['BrowseNode'] and ['Ancestors'] are in a [BrowseNode] Array under you main array. ['Children'] ['BrowseNode']和['Ancestors']位于主数组下的[BrowseNode]数组中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.