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 out the actual € / Euro symbol with this. I just want the plain number, with comma's and decimal points.
Example; 1234.56 should be formatted as 1,234.56 The current output is giving €1,234.56.
Code I'm using:
$array['total_revenue'] = $this
->db
->query($sql)
->row_array()['SUM( booking_total )'];
$formatter = new NumberFormatter('en_GB', NumberFormatter::CURRENCY);
echo $formatter->formatCurrency($array['total_revenue'], 'EUR') . PHP_EOL;
Would anyone have any ideas on how I can fix this up to remove the euro symbol?
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