Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you can not split data on the tabid of the initial, you can use this example</p> <pre><code> class HtmlUlGenerator{ private $_layoutNames=array(); public function addLayoutName($layoutName){ $this-&gt;_layoutNames[]=$layoutName; } public function __toString(){ $retStr="&lt;ul class=\"columns\"&gt;"; foreach ($this-&gt;_layoutNames as $name){ $retStr.="&lt;li&gt;$name&lt;/li&gt;"; } return $retStr."&lt;/ul&gt;"; } } class TabIdDispatcher{ private $_uls=array(); public function addRow($row){ $this-&gt;getUlbyTabId($row['TabId'])-&gt;addLayoutName($row['LayoutName']); } /** * @return HtmlUlGenerator */ private function getUlbyTabId($TabId){ if (!key_exists($TabId, $this-&gt;_uls)) $this-&gt;_uls[$TabId]=new HtmlUlGenerator(); return $this-&gt;_uls[$TabId]; } public function addTable($tableRows){ foreach ($tableRows as $row){ $this-&gt;addRow($row); } } public function __toString(){ $retStr=""; foreach ($this-&gt;_uls as $key=&gt;$ul){ $retStr.="&lt;div id=\"$key\" class=\"tab_content\"&gt; ".$ul."&lt;/div&gt;"; } return $retStr; } } </code></pre> <p>Use it:</p> <pre><code>$table=array(array("TabId"=&gt;1, "LayoutName"=&gt;"g"),array("TabId"=&gt;1, "LayoutName"=&gt;"ffg"),array("TabId"=&gt;1, "LayoutName"=&gt;"gfg"), array("TabId"=&gt;2, "LayoutName"=&gt;"g"),array("TabId"=&gt;2, "LayoutName"=&gt;"ffg"),array("TabId"=&gt;2, "LayoutName"=&gt;"gfg"), array("TabId"=&gt;3, "LayoutName"=&gt;"g"),array("TabId"=&gt;3, "LayoutName"=&gt;"ffg"),array("TabId"=&gt;3, "LayoutName"=&gt;"gfg")) ; $obj=new TabIdDispatcher(); $obj-&gt;addTable($table); echo $obj; </code></pre>
 

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