1

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:

<?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?

fedorqui
  • 275,237
  • 103
  • 548
  • 598
bills
  • 11
  • 1
  • Try `en_GB.UTF8`. That works for me. With `en_GB` I get only the number – nice ass Feb 20 '14 at 12:47
  • Or try `setLocale(LC_ALL, 'en_GB');`, perhaps? – r3mainer Feb 20 '14 at 12:47
  • can you paste a var-dump of number? for me is working if $number is a string or int – mcuadros Feb 20 '14 at 12:48
  • `var_dump($number)` returns `NULL`. I think I'm assigning the variable incorrectly. It seems that `$number = the_field( 'amount_raised' );` is just outputting the value of `amount_raised`, rather than assigning it to `$number` – bills Feb 20 '14 at 13:14

0 Answers0