Hi all,

I'm having one problem with disapling the json data into ul and li based content with using of foreach()
json data from database is

[{"id":1},{"id":2,"children":[{"id":3},{"id":4},{"id":5,"children":[{"id":6},{"id":7},{"id":8}]},{"id":9},{"id":10}]},{"id":11},{"id":12}]





$loop = new RecursiveIteratorIterator(
    new RecursiveArrayIterator(json_decode($get_menu, TRUE)),
    RecursiveIteratorIterator::SELF_FIRST);

    foreach($loop as $mydata)

    {
         echo $mydata
         foreach($mydata->values as $values)
         {
              echo $values->value . "\n";
         }
    }   
echo "<ul>";
foreach($loop as $mydata)
    {
         echo "<li>".$mydata."<ul>";
         foreach($mydata->values as $values)
         {
              echo "<li>".$values->value . "</li>";
         }
         echo "</ul></li>";
    } 
echo "</ul>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.