|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Kian987 Smarty Rookie
Joined: 13 Sep 2012 Posts: 12
|
Posted: Wed Aug 28, 2013 10:43 am Post subject: substr multibyte character with Smarty |
|
|
Hi
I've a problem with a variable. My {$whatever} Smarty variable stores this value "$25.00" and i want to remove the $ symbol. Even if i can do it easly with {$whatever|substr:1}, this method doesn't work with € symbol because it's a multibyte character.
I tried to remove the € from "€25.00" with {$whatever|mb_substr:1} and also with {$whatever|escape:'html':'UTF-8'|substr:1} with no success. How can i fix this issue with Smarty? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Aug 28, 2013 5:34 pm Post subject: |
|
|
try:
Code: | {$whatever|regex_replace:"/[^0-9\.]+/",""} |
ideally, you would assign the currency symbol and amount to smarty separately. |
|
Back to top |
|
Kian987 Smarty Rookie
Joined: 13 Sep 2012 Posts: 12
|
Posted: Thu Aug 29, 2013 7:40 am Post subject: |
|
|
Thank you. I fixed your code (: instead of ,):
Code: | {$whatever|regex_replace:"/[^0-9\.]+/":""} |
Anyway i know that i should make this kind of modifications on top directly with php but as i said above i'm working with obfuscated php files so i can only work on tpl with smarty. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|