Advertisement
Guest User

Untitled

a guest
Aug 16th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1. <?php
  2. $mistic_array_insolvable =
  3.         array (
  4.             'section_id' => 21,
  5.             'section_parent_id' => 0,
  6.             'section_pos' => 30,
  7.             'section_name' => 'Resource Center',
  8.             'has_order' => 1,
  9.             'section_has_hierarchy' => 1,
  10.             'total_entries' => 35,
  11.             'children' =>
  12.                 array (
  13.                     '0' => array
  14.                         (
  15.                             'section_id' => 38,
  16.                             'section_parent_id' => 21,
  17.                             'section_pos' => 31,
  18.                             'section_name' => 'Resource Center',
  19.                             'has_order' => 1,
  20.                             'section_has_hierarchy' => 1,
  21.                             'total_entries' => 35,
  22.                             'children' =>
  23.                                 array (
  24.                                     '0' => array
  25.                                         (
  26.                                             'section_id' => 39,
  27.                                             'section_parent_id' => 38,
  28.                                             'section_pos' => 32,
  29.                                             'section_name' => 'Resource Center',
  30.                                             'has_order' => 1,
  31.                                             'section_has_hierarchy' => 1,
  32.                                             'total_entries' => 35,
  33.                                         ),
  34.  
  35.                                     '1' => array
  36.                                         (
  37.                                             'section_id' => 40,
  38.                                             'section_parent_id' => 38,
  39.                                             'section_pos' => 33,
  40.                                             'section_name' => 'Resource Center',
  41.                                             'has_order' => 1,
  42.                                             'section_has_hierarchy' => 1,
  43.                                             'total_entries' => 35,
  44.                                         )
  45.                                 )
  46.                         )
  47.                 )
  48.         );
  49.    
  50.    
  51. function deep_in_array($target) {
  52.     $in_depth = array();
  53.     if(array_key_exists('children',$target)){
  54.         $in_depth[$target['section_id']] = array();
  55.         foreach($target['children'] as $children){
  56.             $in_depth[$target['section_id']][$children['section_id']] = array();
  57.             $in_depth[$target['section_id']][$children['section_id']] = deep_in_array($children);
  58.         }
  59.         $in_depth['section_name'] = $target['section_name'];
  60.         return $in_depth;
  61.     }
  62.     $in_depth['section_name'] = $target['section_name'];
  63.     return $in_depth;
  64. }
  65.  
  66. var_dump('<pre>',deep_in_array($mistic_array_insolvable));
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement