0
Good use of php’s number_format function, to format values in the pattern I want.
I do so:
number_format($valor_form, 2, '.', '');
The problem is that at some point the user informs a very crazy value in the form, and causes an error in the function, as it arrives a string 'Infinity'.
My question is how to check if it is a string, and if it is I have to change the value of the variable 'value_form' to 0.
Can someone help me?
Hello, I don’t know if it’s the right answer but try it this way: number_format($valor_form*1, 2, '.', '');
– Tiago Gomes
I didn’t quite understand what you tried to do. What I want to check is if there is a number in $valor_form
– Hugo Borges
Multiplying a string equals 0. It also has the function is_numeric()
– Tiago Gomes
This number is integer or can have decimal?
– Antonio Alexandre
well, it can be integer or decimal
– Hugo Borges