|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Budda Smarty Regular
Joined: 19 Apr 2003 Posts: 53 Location: Lymm, Cheshire. UK
|
Posted: Tue May 27, 2003 4:14 pm Post subject: string / integer comparisons |
|
|
I think i've found a problem with the latest stable Smart distro.
I have an array passed to the template. It's a number of objects indexed by an integer in the array. however one of the array indexes is a workd 'Count'.
I wish to use a Code: | {foreach item=article key=key from=$newsArticles} | on the array, but the avoid the array element whos index is 'Count'.
This doesn't work to well when I use something like Code: | {if $key != "Count"}
...stuff...
{/if} | because it appears "Count" is equivalent to the integer 0. A type casting issue. Is it possible to get around this? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue May 27, 2003 7:10 pm Post subject: |
|
|
yep, smarty shares this type-casting-issue with php. to get around this use "===" and "!==" if you want to compare against value *and* type.
greetings
messju |
|
Back to top |
|
Budda Smarty Regular
Joined: 19 Apr 2003 Posts: 53 Location: Lymm, Cheshire. UK
|
Posted: Wed May 28, 2003 8:49 am Post subject: |
|
|
Solution worked, thanks! First time i've ever had to use === and !== |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|