|
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 |
pierrot10 Smarty n00b
Joined: 08 Apr 2012 Posts: 4
|
Posted: Sun Apr 08, 2012 8:13 pm Post subject: How can I know if an array contain a data |
|
|
Dear All,
I ma new with smarty.
I have an array {$myarray} and I can not use a foreach like this
Code: | {foreach from=$myarray key=key item=myarrayItem name=myarrayName}
{/foreach} |
I woule like to do as we do with php
Code: | in_array('toto', $myarray) |
How can I do with smarty?
I need to get a true if my value is in the array and a false if not.
Many thank for your help |
|
Back to top |
|
kataxxx Smarty Rookie
Joined: 08 Apr 2012 Posts: 10
|
Posted: Sun Apr 08, 2012 8:18 pm Post subject: |
|
|
Try
Code: | {if isset($myarrayItem.toto) }
true
{else}
false
{/else} |
This should work. |
|
Back to top |
|
pierrot10 Smarty n00b
Joined: 08 Apr 2012 Posts: 4
|
Posted: Sun Apr 08, 2012 8:28 pm Post subject: |
|
|
No I found the solution:
Code: | {if in_array('toto', $db_id_productsPool)} |
|
|
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
|