Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addParent($array, $parent = null) {
- $result = [];
- foreach ($array as $key => $value) {
- if (is_null($parent)) {
- $result[] = $value['@attributes'];
- $result = array_merge($result, addParent($value['category'], $value['@attributes']['code']));
- } else {
- $result[] = array_merge($value['@attributes'], ['code_parent' => $parent]);
- }
- }
- return $result;
- }
- $result = addParent($getSection);
- print_r($result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement