Unexpected result using money_format

I’m trying to assign the output of a custom wordpress field to $number and then use $number inside money_format. My expected output is £ value_in_number, but I’m actually getting value_in_number £.

Here is my code:

Read More
<?php
    $number = the_field( 'amount_raised' ); 
    setLocale(LC_MONETARY, 'en_GB');
    echo money_format('%n', $number) . "n";
?>

If i assign an actual value to $number I get my expected result, but adding the_field( 'amount_raised' ); switches the symbol and value around. amount_raised is a number field.

Any ideas?

Related posts

Leave a Reply