Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

analog of strstr() (search in variable/string) in Smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
MaoDzeDun
Smarty n00b


Joined: 03 Sep 2005
Posts: 2

PostPosted: Sat Sep 03, 2005 8:48 pm    Post subject: analog of strstr() (search in variable/string) in Smarty Reply with quote

Hello!
Need some help!
I am looking for analog of PHP function strstr() (search in variable/string) in Smarty.
I am new in Smarty, but I'll try to make an example on PHP

Code:

<?
$var1 = "AAA Some text ";
if (strstr($var1, "AAA"))
   {
      echo" \"AAA\" is present in var1";
   }
else
   {
      echo" There is no \"AAA\" in var1";
   }
?>

So, I need to know a Smarty function, which searches in variable.
In documentation, there is only description of regex_replace function, but this function searches and replace in variable. And I need only a search function.
Many thanks for your help!!!
Back to top
View user's profile Send private message
messju
Administrator


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

PostPosted: Sat Sep 03, 2005 9:04 pm    Post subject: Reply with quote

you can use php-function inside {if}
like:

Code:
{if strstr($haystack, $needle)}
...
{/if}


or

Code:
{if strpos($haystack, $needle) !== null}
...
{/if}
Back to top
View user's profile Send private message Send e-mail Visit poster's website
MaoDzeDun
Smarty n00b


Joined: 03 Sep 2005
Posts: 2

PostPosted: Sat Sep 03, 2005 9:29 pm    Post subject: Reply with quote

messju wrote:
you can use php-function inside {if}
like:

Code:
{if strstr($haystack, $needle)}
...
{/if}


or

Code:
{if strpos($haystack, $needle) !== null}
...
{/if}


Many thanx!!!
And one more question, please!
Can I use any PHP function in Smarty code???
Back to top
View user's profile Send private message
messju
Administrator


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

PostPosted: Sun Sep 04, 2005 2:58 pm    Post subject: Reply with quote

MaoDzeDun wrote:
Can I use any PHP function in Smarty code???


only as modifiers, see:
http://smarty.php.net/manual/en/language.modifiers.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General 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