I have the following php code:
'fees' => number_format($_POST['fees'],2)
The sample JSON is:
{
"fees":"74.00"
}
I need the value for fees to be a double rather than being a string.
I tried doing this:
'fees' => (double)number_format($_POST['fees'],2)
But it does not seem to work. Is there any way to make fees a double rather than it being a string?
If you want to convert the string value to float , you can use following code. But in Json it should be a string .
$string='123.56999';
$float = doubleval(number_format($string,2));
var_dump($float);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.