0

私は2つの配列を持っています:

  1. 印刷用の配列。各アイテムは1行のテーブルです。

    array(
      [1] => array(
        [data] = array(
          [parent] = NULL,
          [depth] = 1
        );
      );
    
      [2] => array(
        [data] = array(
          [parent] = 1,
          [depth] = 2
        );
      );
    
      [3] => array(
        [data] = array(
          [parent] = 1,
          [depth] = 2
        );
      );
    
      [4] => array(
        [data] = array(
          [parent] = 2,
          [depth] = 3
        );
      );
    
    
      [5] => array(
        [data] = array(
          [parent] = NULL,
          [depth] = 1
        );
      );
    
      [6] => array(
        [data] = array(
          [parent] = 5,
          [depth] = 2
        );
      );
    );
    
  2. 次元順に並べる配列

    array(
      [1] => array(
        [data] = array(
          [parent] = NULL,
          [depth] = 1
        );
        [children] => array(
          [2] => array(
            [data] = array(
              [parent] = 1,
              [depth] = 2
            );
            [children] => array(
              [4] => array(
                [data] = array(
                  [parent] = 2,
                  [depth] = 3
                );
              );
            );
          );
    
          [3] => array(
            [data] = array(
              [parent] = 1,
              [depth] = 2
            );
          );
        );
      );
      [5] => array(
        [data] = array(
          [parent] = NULL,
          [depth] = 1
        );
        [children] => array(
          [6] => array(
            [data] = array(
              [parent] = 5,
              [depth] = 2
            );
          );
        );
      );
    );
    

そして、私はこの配列を取得したいと思います(それはホイッチからは関係ありません):

    array(
      [1] => array(
        [1] = array(
          [parent] = NULL,
          [depth] = 1
        );
      );

      [2] => array(
        [1] = array(
          [parent] = NULL,
          [depth] = 1
        );
        [2] = array(
          [parent] = 1,
          [depth] = 2
        );
      );

      [3] => array(
        [1] = array(
          [parent] = NULL,
          [depth] = 1
        );
        [2] = array(
          [parent] = 1,
          [depth] = 2
        );
      );

      [4] => array(
        [1] = array(
          [parent] = NULL,
          [depth] = 1
        );
        [2] = array(
          [parent] = 1,
          [depth] = 2
        );
        [3] = array(
          [parent] = 2,
          [depth] = 3
        );
      );

      [5] => array(
        [1] = array(
          [parent] = NULL,
          [depth] = 1
        );
      );

      [6] => array(
        [1] = array(
          [parent] = NULL,
          [depth] = 1
        );
        [2] = array(
          [parent] = 5,
          [depth] = 2
        );
      );
    );

IDですべての親を見ることができる配列です。誰か知ってる?

4

0 に答える 0