| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
smarty help please? can I compare the first x characters of a variable? | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() 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
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#2
|
|||||||
|
|||||||
![]() {if $variablename|substr:0:5 eq '1ZAB1'}
|
|||||||
#3
|
|||||||
|
|||||||
![]() Quote:
that is just BEAUTIFUL! thank you! Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#4
|
|||||||
|
|||||||
![]() 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
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#5
|
|||||||||
|
|||||||||
![]() PHP Code:
__________________
Eugene Kaznacheev, Evangelist/Product Manager at Ecwid: http://www.ecwid.com/ (since Sept 2009) ex-Head of X-Cart Tech Support Department ex- X-Cart Hosting Manager - X-Cart hosting ex-X-Cart Technical Support Engineer Note: For the official guaranteed tech support services please turn to the Customers HelpDesk. |
|||||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|