Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

substr multibyte character with Smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Kian987
Smarty Rookie


Joined: 13 Sep 2012
Posts: 12

PostPosted: Wed Aug 28, 2013 10:43 am    Post subject: substr multibyte character with Smarty Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Aug 28, 2013 5:34 pm    Post subject: Reply with quote

try:

Code:
{$whatever|regex_replace:"/[^0-9\.]+/",""}


ideally, you would assign the currency symbol and amount to smarty separately.
Back to top
View user's profile Send private message Visit poster's website
Kian987
Smarty Rookie


Joined: 13 Sep 2012
Posts: 12

PostPosted: Thu Aug 29, 2013 7:40 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP