'"Notice: A non well formed numeric value encountered" PHP [duplicate]
I am getting the following error as a result of a calculation. I couldn't see any problem with the exit code. So why am I getting this error and how can I fix it?
// b2Cost = 19.020843;
return (float)number_format((float)str_replace(",", ".", $b2Cost), 2, ".", "");
Error:
Notice: A non well formed numeric value encountered
Solution 1:[1]
Try
return (float)number_format((float)str_replace(",", ".", (string) $b2Cost), 2, ".", "");
But if you just want to shorten the float, take a look at https://www.php.net/manual/en/function.round.php
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Guido Faecke |
