For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > August 2004 > using index_prev with foreach









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author using index_prev with foreach
Hiro Protagonist

2004-08-04, 9:06 am

Hi,

I have an array, with e.g. this keys: unit, name, phone.
I would like to loop through the array with foreach (works fine) and
would like to put out a extra <tr>, if the unit changes. So the output
will be grouped by unit.

I tried this:

{foreach name=members from=$arrayMembers item=mem}
{if $smarty.foreach.members.first or
$smarty.foreach.members.index_prev.unit ne $smarty.foreach.members.unit}
Special unit-Row
{/if}
Normal-Row
{/foreach}

Doesn't work.

It works with sections, but i thought, doing it with foreach would make
the code simpler. Any ideas?

thx

Hiro


--
Hi! I'm a .sig virus! Copy me to your .sig!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com