Recursivity in PHP - How to generate the data structure for bootstrap-treeview

0

I need help to generate the data structure requested by bootstrap-treeview ( link )

In my Table I have: (id, father_id, name)

How can I create the following structure using PHP ?????

var tree = [
  {
    text: "Parent 1",
    nodes: [
      {
        text: "Child 1",
        nodes: [
          {
            text: "Grandchild 1"
          },
          {
            text: "Grandchild 2"
          }
        ]
      },
      {
        text: "Child 2"
      }
    ]
  },
  {
    text: "Parent 2"
  },
  {
    text: "Parent 3"
  },
  {
    text: "Parent 4"
  },
  {
    text: "Parent 5"
  }
];
    
asked by Gabriel Surraco 22.06.2018 в 02:32
source

0 answers