|
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 |
MaoDzeDun Smarty n00b
Joined: 03 Sep 2005 Posts: 2
|
Posted: Sat Sep 03, 2005 8:48 pm Post subject: analog of strstr() (search in variable/string) in Smarty |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Sep 03, 2005 9:04 pm Post subject: |
|
|
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 |
|
MaoDzeDun Smarty n00b
Joined: 03 Sep 2005 Posts: 2
|
Posted: Sat Sep 03, 2005 9:29 pm Post subject: |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
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
|