Reputation: 105
I want to remove rest string where matches for e.g. "exampleword" in smarty. Or remove last 100 character of string? Can make with trim function in smarty or some function with PHP?
Upvotes: 0
Views: 121
Reputation: 7911
You can use substr()
, example code:
echo substr("string of 100 characters ore more...", -5); // re...
echo substr("string of 100 characters ore more...", 0, -5); // string of 100 characters ore mo
$smarty = new Smarty;
$smarty->assign('name', substr('george smith', 0, -3));
$smarty->display('index.tpl');
Look here in example #1 for negative start or length in example #2 (depending on which part you want to return) but be sure to check if the string is actually larger then 100 characters (with strlen()
) before you do this.
Upvotes: 1