Home > Archive > PHP Smarty Templates > August 2005 > Re: [SMARTY] foreach in reverse
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 |
Re: [SMARTY] foreach in reverse
|
|
|
| --- Matt Warden <mwarden@gmail.com> wrote:
> smarties,
>
> I was hoping that there was a way to do a foreach in reverse (i.e.,
> starting with the last element and ending with the first). After
> seeing that there doesn't seem to be, I tried to work out the
> equivalent of a 'foreach in reverse' with sections and a negative
> step. Does someone have an example of doing this?
Hi.
I assume that this would work:
{foreach from=$myarray|@array_reverse:true item=foo} ...
See:
- http://smarty.php.net/manual/en/language.modifiers.php
- http://php.net/array_reverse
HTH
________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
| |
| Matt Warden 2005-08-12, 10:33 pm |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
boots wrote:
> I assume that this would work:
>
> {foreach from=$myarray|@array_reverse:true item=foo} ...
Worked great (why didn't I think of that?). Thanks.
- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFC/ S7vAQ0d4HGyPE8RAjPiAJ9T+CEH1qoL1HC+O52XL
O19Voj2VwCfZosj
3uFjFS6yK7TRakrT7eLBoMA=
=cjXB
-----END PGP SIGNATURE-----
|
|
|
|
|