Removing currency symbol from formatCurrency

前端 未结 3 864
-上瘾入骨i
-上瘾入骨i 2021-01-19 06:26

I\'m trying to format revenue totals as grabbed from a db, and using php\'s NumberFormatter class, with the formatCurrency method.

However, I do not want to print ou

3条回答
  •  耶瑟儿~
    2021-01-19 06:52

    A simple regex is a quick fix for your problem. Try;

    $actual = $formatter->formatCurrency($array['total_revenue'], 'EUR') . PHP_EOL;
    $output = preg_replace( '/[^0-9,"."]/', '', $actual );
    echo $output;
    

    Hope this helps

提交回复
热议问题