title: How to get dropdown dynamically with ul li inside ul using php?
body: <p>I have a <code>ul li</code> with <code>parentid</code> . I want all <code>ul li</code> with <code>parentid</code> but I'm getting multiple loops.  The first steps and last are under same <code>parentid</code>.<br>
  <a href="https://i.stack.imgur.com/zuTph.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zuTph.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;ul class="section-list"&gt; 
  &lt;?php   
      if(count($outArrResults)&gt;0){    
          for($i=0; $i&lt;count($outArrResults); $i++){
              ?&gt;
                  &lt;li class="o-view"&gt;
                      &lt;a href='javascript:void(0);'&gt;
                          &lt;h4 class="tit-section xsm"&gt;
                              &lt;?php echo isset($outArrResults[$i]['cName']) ?$outArrResults[$i]['cName'] : '';?&gt;
                          &lt;/h4&gt;
                      &lt;/a&gt;
                      &lt;ul&gt;
                          &lt;?php
                              for($s=0; $s&lt;count($outArrResults); $s++){
                                  $contentSlugUrl = isset($outArrResults[$s]['conSName']) ? $outArrResults[$s]['conSName']:'';
                                  $contentMenuTitle = isset($outArrResults[$s]['conMTitle']) ? $outArrResults[$s]['conMTitle']:'';
                                  if($contentMenuTitle!=''){
                                      ?&gt;
                                          &lt;li&gt;
                                              &lt;a href='&lt;?php echo $config['LIVE_URL'].'courses/'.$pAction1.'/'.$pAction2.'/'.$contentSlugUrl;?&gt;'&gt;
                                                  &lt;span&gt;&lt;?php echo $contentMenuTitle;?&gt;&lt;/span&gt;
                                              &lt;/a&gt;
                                          &lt;/li&gt;
                                      &lt;?php
                                  }
                              }
                          ?&gt;
                      &lt;/ul&gt;
                  &lt;/li&gt;
              &lt;?php
          }
      } else {
          echo "No Results";
      }
  ?&gt;
  </code></pre>
  
  <p></p>