![]() |
smarty help please? can I compare the first x characters of a variable?
Smarty help, please?
I am seeking to compare the first x characters of a var string - for example: let's says there's a variable: $variablename {if $variablename 1st 5 characetrs = 1ZAB1} then show something {else} show something else. Can this be done in smarty? My goal is to trap the first 5 characters of a tracking number -- and if it looks like 1ZAB1, then it is clearly UPS, and I will show a UPS tracking link. ELSE it can only be USPS (and a different tracking link) Any ideas? Thanks. Jeremy |
Re: smarty help please? can I compare the first x characters of a variable?
{if $variablename|substr:0:5 eq '1ZAB1'}
|
Re: smarty help please? can I compare the first x characters of a variable?
Quote:
that is just BEAUTIFUL! thank you! Jeremy |
Re: smarty help please? can I compare the first x characters of a variable?
question: can the substr be case iNSEnsiTIvE?
so: if the string is 1zAb12v41234567 OR the string is: 1ZAB12V41234567 the results are the same? is the there a smarty "case doesn't matter" setting? thx Jeremy |
Re: smarty help please? can I compare the first x characters of a variable?
PHP Code:
|
All times are GMT -8. The time now is 07:04 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.