original_string: public static function listToMultiArray($array)
      {
          $nested = [];
          $depths = [];
  
          foreach ($array as $key => $arr) {
  
              if ($arr['depth'] == 0) {
                  $nested[$key] = $arr;
              } else {
                  $parent =& $nested;
  
                  for ($i = 1; $i <= ($arr['depth']); $i++) {
                      $parent =& $parent[$depths[$i]];
                  }
  
                  $parent['pages'][$key] = $arr;
              }
  
              $depths[$arr['depth'] + 1] = $key;
          }
  
          return $nested;
      }
code: public static function listToMultiArray($array)
      {
          $nested = [];
          $depths = [];
  
          foreach ($array as $key => $arr) {
  
              if ($arr['depth'] == 0) {
                  $nested[$key] = $arr;
              } else {
                  $parent =& $nested;
  
                  for ($i = 1; $i <= ($arr['depth']); $i++) {
                      $parent =& $parent[$depths[$i]];
                  }
  
                  $parent['pages'][$key] = $arr;
              }
  
              $depths[$arr['depth'] + 1] = $key;
          }
  
          return $nested;
      }
code_tokens: public static function listToMultiArray ( $ array ) { $ nested = [ ] ; $ depths = [ ] ; foreach ( $ array as $ key => $ arr ) { if ( $ arr [ 'depth' ] == 0 ) { $ nested [ $ key ] = $ arr ; } else { $ parent = & $ nested ; for ( $ i = 1 ; $ i <= ( $ arr [ 'depth' ] ) ; $ i ++ ) { $ parent = & $ parent [ $ depths [ $ i ] ] ; } $ parent [ 'pages' ] [ $ key ] = $ arr ; } $ depths [ $ arr [ 'depth' ] + 1 ] = $ key ; } return $ nested ; }
docstring: transform a list into a multidimensional array
  using a depth value
  
  @param array $array
  @return array
docstring_tokens: transform a list into a multidimensional array using a depth value