Re: A bug in section loop
| From: | Ivo Jansch | Date: | Tue, 17 Jul 2001 14:09:20 +0000 |
| Subject: | Re: A bug in section loop | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1181@lists.php.net to get a copy of this message | ||
Hi,
Monte Ohrt wrote:
And how are you going to access the index of other variables within the section loop using a foreach() loop? That is why we didn't use it.In normal situations where you have to loop other variables, your arrays are contiguous. If your loop= array is not contiguous, than probably the arrays you use inside the loop are not contiguous as well (99% of the time). To handle both, you could do the following: suppose this is your loop: {section name="sec1" loop=names} {names[sec1] ({streets[sec1]}) {/section} so there are two arrays.. now suppose both are not contiguous (for some stupid reason I can't think of), the following loop will work: foreach (array_keys($names) as $key) { echo $names[$key]." (".$streets[$key].")"; } (of course, in smarty that will be full of $_smarty_sections stuff, but I think its doable) Greetings, Ivo -- Ivo Jansch <ivo@ibuildings.nl> ibuildings.nl BV - information technology http://www.ibuildings.nl