Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could remove the first and last elements off the array and process them separately.<br> Like this:</p> <pre><code>&lt;?php $array = something(); $first = array_shift($array); $last = array_pop($array); // do something with $first foreach ($array as $item) { // do something with $item } // do something with $last ?&gt; </code></pre> <p>Removing all the formatting to CSS instead of inline tags would improve your code and speed up load time.</p> <p>You could also avoid mixing HTML with php logic whenever possible.<br> Your page could be made a lot more readable and maintainable by separating things like this:</p> <pre><code>&lt;?php function create_menu($params) { //retirive menu items //get collection $collection = get('xxcollection') ; foreach($collection as $c) show_collection($c); } function show_subcat($val) { ?&gt; &lt;div class="sub_node" style="display:none"&gt; &lt;img src="../images/dtree/join.gif" align="absmiddle" style="padding-left:2px;" /&gt; &lt;a id="'.$val['xsubcatid'].'" href="javascript:void(0)" onclick="getProduct(this , event)" class="sub_node_links" &gt; &lt;?php echo $val['xsubcatname']; ?&gt; &lt;/a&gt; &lt;/div&gt; &lt;?php } function show_cat($item) { ?&gt; &lt;div class="node" &gt; &lt;img src="../images/dtree/plus.gif" align="absmiddle" class="node_item" id="plus" /&gt; &lt;img src="../images/dtree/folder.gif" align="absmiddle" id="folder"&gt; &lt;?php echo $item['xcatname']; ?&gt; &lt;?php $subcat = get_where('xxsubcategory' , array('xcatid'=&gt;$item['xcatid'])) ; foreach($subcat as $val) show_subcat($val); ?&gt; &lt;/div&gt; &lt;?php } function show_collection($c) { ?&gt; &lt;div class="parent" style="direction:rtl"&gt; &lt;img src="../images/dtree/minus.gif" align="absmiddle" class="parent_item" id="minus" /&gt; &lt;img src="../images/dtree/base.gif" align="absmiddle" id="base"&gt; &lt;?php echo $c['xcollectionname']; ?&gt; &lt;?php //get categories $cat = get_where('xxcategory' , array('xcollectionid'=&gt;$c['xcollectionid'])); foreach($cat as $item) show_cat($item); ?&gt; &lt;/div&gt; &lt;?php } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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