![]() |
Using integers within Smarty
How do you create an integer variable, assign it a value, compare the value of the variable with an integer and then increment the variable using Smarty?
I've tried to do this but always manage to print out the arithmatic, e.g. I want to count the number of lines of HTML that I create so I have a variable $lines which I set to 0, $lines=0. For each line of HTML created I increment the variable, $lines=$lines+1. I then test to see if 12 or more lines of HTML have been created, {if $lines >= 12} When I do this the resultant HTML shows the variable being incremented, e.g. line 4 has "0+1+1+1+1" I don't want to output numbers I just want to use them to control my output. |
Re: Using integers within Smarty
Quote:
Create value: PHP Code:
Increment: PHP Code:
Compare: PHP Code:
|
Re: Using integers within Smarty
Thanks Yurij,
That works a treat, and I would never have guessed the syntax for incrementing. |
Re: Using integers within Smarty
Don't use math - its slow. Just use assign:
PHP Code:
|
All times are GMT -8. The time now is 10:21 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.