Problem with variable being cast to int
I get a float value from a xml file and I assign this value to a variable
$value = 13.80;
When I do number_format($value,2,".",","); I get NULL. Any ideas why?
When I try echo empty($value) ? '0' : $value; I get 13.80 showing it´s not null/empty.
I am using PHP 5.3.13
Re: Problem with variable being cast to int
You must be doing something else then...because there's nothing wrong and it works.
Note that you don't need the period or comma because those are already the default parameters.
PHP Code:
<?php
$value = 13.80;
$value = number_format($value, 2);
echo empty($value) ? '0' : $value;
?>