2

再帰配列をループし、php を使用して複数レベルのネストされたリストを作成するロジックについて、誰か助けてください。トップレベルのリストノードを超えることにあまり成功していません。

以下の配列を参照してください。

Dump => array(6) {
  [0] => array(5) {
    ["id"] => string(1) "1"
    ["label"] => string(13) "address types"
    ["slug"] => string(17) "admin/addresstype"
    ["parent_id"] => string(1) "0"
    ["has_children"] => bool(false)
  }
  [1] => array(5) {
    ["id"] => string(1) "3"
    ["label"] => string(9) "dashboard"
    ["slug"] => string(15) "admin/dashboard"
    ["parent_id"] => string(1) "0"
    ["has_children"] => bool(false)
  }
  [2] => array(6) {
    ["id"] => string(1) "5"
    ["label"] => string(16) "feature category"
    ["slug"] => string(21) "admin/featurecategory"
    ["parent_id"] => string(1) "0"
    ["has_children"] => bool(true)
    ["children"] => array(2) {
      [0] => array(6) {
        ["id"] => string(1) "4"
        ["label"] => string(7) "feature"
        ["slug"] => string(13) "admin/feature"
        ["parent_id"] => string(1) "5"
        ["has_children"] => bool(true)
        ["children"] => array(2) {
          [0] => array(5) {
            ["id"] => string(1) "2"
            ["label"] => string(6) "status"
            ["slug"] => string(12) "admin/status"
            ["parent_id"] => string(1) "4"
            ["has_children"] => bool(false)
          }
          [1] => array(5) {
            ["id"] => string(1) "7"
            ["label"] => string(4) "menu"
            ["slug"] => string(10) "admin/menu"
            ["parent_id"] => string(1) "4"
            ["has_children"] => bool(false)
          }
        }
      }
      [1] => array(5) {
        ["id"] => string(1) "9"
        ["label"] => string(17) "subscription type"
        ["slug"] => string(22) "admin/subscriptiontype"
        ["parent_id"] => string(1) "5"
        ["has_children"] => bool(false)
      }
    }
  }
  [3] => array(5) {
    ["id"] => string(1) "6"
    ["label"] => string(8) "industry"
    ["slug"] => string(14) "admin/industry"
    ["parent_id"] => string(1) "0"
    ["has_children"] => bool(false)
  }
  [4] => array(5) {
    ["id"] => string(1) "8"
    ["label"] => string(12) "subscription"
    ["slug"] => string(18) "admin/subscription"
    ["parent_id"] => string(1) "0"
    ["has_children"] => bool(false)
  }
  [5] => array(5) {
    ["id"] => string(2) "10"
    ["label"] => string(4) "user"
    ["slug"] => string(10) "admin/user"
    ["parent_id"] => string(1) "0"
    ["has_children"] => bool(false)
  }
}

よろしくお願いします

4

1 に答える 1