I have develop a payment gateway where an admin can put their invoice fee. Problem is this, when user update fee 15.20 then its OK but when user insert price as 15,20 then its make problem means he is using comma(,) as decimal separated and dot(.) as thousand separated.

Please anyone suggests how to parse string 15.123,98 to 15,123.98 is their any magento function to do this?


You could use the function format from the model 'directory/currency'. This will try to format any string as a currency. The second parameter is an array that can contain some cool features like 'display'=>Zend_Currency::NO_SYMBOL if you do not want to show the symbol.

echo Mage::getModel('directory/currency')->format(

The options you can add to the display array can be found in /lib/Zend/Currency.php and are:


Or if you want to load the currency format from a store you can do the following.

$currency = Mage::app()->getStore($storeId)->getBaseCurrency();
echo $currency->format('15.123,98');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.