Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

string / integer comparisons

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
Budda
Smarty Regular


Joined: 19 Apr 2003
Posts: 53
Location: Lymm, Cheshire. UK

PostPosted: Tue May 27, 2003 4:14 pm    Post subject: string / integer comparisons Reply with quote

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? Confused
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue May 27, 2003 7:10 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Budda
Smarty Regular


Joined: 19 Apr 2003
Posts: 53
Location: Lymm, Cheshire. UK

PostPosted: Wed May 28, 2003 8:49 am    Post subject: Reply with quote

Solution worked, thanks! First time i've ever had to use === and !== Laughing
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP