Re: [SMARTY] selecting 4 characters starting from right of string

From: Date: Thu, 17 Feb 2005 08:59:37 +0000
Subject: Re: [SMARTY] selecting 4 characters starting from right of string
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12247@lists.php.net to get a copy of this message
Hi, first of all, it has to be either (strlen()-4) or "jpg" instead of ".jpg". in smarty you can use this: {assign var="str" value="alp.jpg"} {if substr($str,strlen($str)-4,strlen($str)) == ".jpg"} Do this {else} Do that {/if} On Thu, Feb 17, 2005 at 04:47:30AM +0200, alp güneysel wrote: > How can i get something like this inside of template for a variable in a > section loop? > > > ================= > $str="alp.jpg"; > $length=strlen($str); > $suffix= substr($str,$length-3, $length); > > if ($suffix==".jpg"){ > do this > }else{ > Do that > } > ================= > > i dont want to handle it in php, i want to be able to check it in my > template... is it possible? > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Lassen Sie Ihren Gedanken freien Lauf... z.B. per FreeSMS GMX bietet bis zu 100 FreeSMS/Monat: http://www.gmx.net/de/go/mail

« previous php.smarty.general (#12247) next »