Web Hosting Talk







View Full Version : Smarty preg_match?


siforek
05-23-2009, 02:30 PM
I need to return an if statement true if a smarty variable starts with "3,"..

preg_match with php works great, but I've got to access a similar function within a tpl for a loop.. Any help is appreciated. Thanks

siforek
05-23-2009, 02:42 PM
Nevermind..

{if preg_match("3,", $foo)}

That was easy.

HivelocityDD
05-24-2009, 10:39 AM
I am not sure the above code should work or not

But usually you can include php code inside tpl file using


{php}

//PHP code

if(preg_match("3,", $foo)) {
// do something
}

{/php}

siforek
05-24-2009, 01:50 PM
What I used worked.. For what I was doing I needed to execute it outside any php tags.