Re: [SMARTY] random number
| From: | messju mohr | Date: | Mon, 12 May 2003 19:34:33 +0000 |
| Subject: | Re: [SMARTY] random number | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9530@lists.php.net to get a copy of this message | ||
On Mon, May 12, 2003 at 05:11:18PM +0200, Mattia wrote:
> is it possible to generate a random number unsing smarty templates
> instruction, without generating it in your PHP file?
you can use php-functions as modifiers:
{"10"|mt_rand:20}
will produce a random-number between 10 and 20 (both
inclusive).
beware that with php prior to version 4.2.0 you have seed the prng
with mt_srand() before using mt_rand.
the syntax above is of course not very elegant, consider writing your
own plugin-function or modifier if you have to use it more often.
> _M_