Note that there are some explanatory texts on larger screens.

plurals
  1. POcreate unlimited ul li tag from fetch Array (for list)
    text
    copied!<p>I'm going to make a unlimited list use li and ul tags from my Array results of PDO(fetched)</p> <p><strong>my Array :</strong></p> <pre><code>Array ( [0] =&gt; Array ( [category_label] =&gt; catLevel4 [category_id] =&gt; 22 [category_owner] =&gt; 21 ) [1] =&gt; Array ( [category_label] =&gt; catLevel3 [category_id] =&gt; 21 [category_owner] =&gt; 20 ) [2] =&gt; Array ( [category_label] =&gt; catLevel2 [category_id] =&gt; 23 [category_owner] =&gt; 8 ) [3] =&gt; Array ( [category_label] =&gt; catLevel2 [category_id] =&gt; 24 [category_owner] =&gt; 8 ) [4] =&gt; Array ( [category_label] =&gt; catLevel2 [category_id] =&gt; 20 [category_owner] =&gt; 6 ) [5] =&gt; Array ( [category_label] =&gt; catLevel1 [category_id] =&gt; 6 [category_owner] =&gt; 0 ) [6] =&gt; Array ( [category_label] =&gt; catLevel1 [category_id] =&gt; 7 [category_owner] =&gt; 0 ) [7] =&gt; Array ( [category_label] =&gt; catLevel1 [category_id] =&gt; 8 [category_owner] =&gt; 0 ) ) </code></pre> <p><strong>i want :</strong></p> <pre><code>catLevel1 catLevel2 catLevel3 catLevel4 catLevel1 catLevel1 catLevel2 catLevel2 </code></pre> <p>i made a function for convert :</p> <pre><code>function getCategory($parentCategoryId,$data) { foreach($data as $row){if($row['category_owner']==$parentCategoryId){?&gt; &lt;li catId='&lt;?php echo $row['category_id']?&gt;'&gt;&lt;a&gt;&lt;?php echo $row['category_label'];?&gt;&lt;/a&gt; &lt;ul&gt; &lt;?php getCategory($row['category_id'],$data) ;?&gt; &lt;/ul&gt; &lt;/li&gt; &lt;?php };} } echo getCategory(0,$this-&gt;categorysList); </code></pre> <p>this function is very good working for me , <strong>But create null <code>&lt;ul&gt;&lt;/ul&gt;</code></strong> for all items !</p> <p>I appreciate your help to build a standard function ;D</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload