Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mistic_array_insolvable =
- array (
- 'section_id' => 21,
- 'section_parent_id' => 0,
- 'section_pos' => 30,
- 'section_name' => 'Resource Center',
- 'has_order' => 1,
- 'section_has_hierarchy' => 1,
- 'total_entries' => 35,
- 'children' =>
- array (
- '0' => array
- (
- 'section_id' => 38,
- 'section_parent_id' => 21,
- 'section_pos' => 31,
- 'section_name' => 'Resource Center',
- 'has_order' => 1,
- 'section_has_hierarchy' => 1,
- 'total_entries' => 35,
- 'children' =>
- array (
- '0' => array
- (
- 'section_id' => 39,
- 'section_parent_id' => 38,
- 'section_pos' => 32,
- 'section_name' => 'Resource Center',
- 'has_order' => 1,
- 'section_has_hierarchy' => 1,
- 'total_entries' => 35,
- ),
- '1' => array
- (
- 'section_id' => 40,
- 'section_parent_id' => 38,
- 'section_pos' => 33,
- 'section_name' => 'Resource Center',
- 'has_order' => 1,
- 'section_has_hierarchy' => 1,
- 'total_entries' => 35,
- )
- )
- )
- )
- );
- function deep_in_array($target) {
- $in_depth = array();
- if(array_key_exists('children',$target)){
- $in_depth[$target['section_id']] = array();
- foreach($target['children'] as $children){
- $in_depth[$target['section_id']][$children['section_id']] = array();
- $in_depth[$target['section_id']][$children['section_id']] = deep_in_array($children);
- }
- $in_depth['section_name'] = $target['section_name'];
- return $in_depth;
- }
- $in_depth['section_name'] = $target['section_name'];
- return $in_depth;
- }
- var_dump('<pre>',deep_in_array($mistic_array_insolvable));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement