I am using the Advanced Custom Fields wordpress plugin and I am outputting the value of one of the fields: the_field('Price'); which gives a number .
I want to format this number as pounds sterling with commas.
I am having some problems outputting it. It seems to be to do with which comes first the outputted function value or the number format function.
$money = the_field('Price');
echo '£' . number_format($money,0, '.', '');
This doesn’t work and outputs e.g. 300000£0
thanks in advance.
It looks like
the_field()doesn’t return anything but echoes instead.You can write your own custom function:
and use that in place of
the_field()or capture output using
ob_start()andob_get_clean()and pass it tonumber_format()