I have a string like:
R$10,25
I need to convert it to:
10.25
I'm trying with:
$value = 'R$10,20';
$value_subs = str_replace(array('R', '$'), '', $value);
$value_formated = number_format($value_subs, 2, ',', '.');
After I will compare the $value_formated value with another to proceed the code, like:
$another_value = 20.40;
if($value_formated <= $another_value)
{
//Error
}
else
{
//Proceed
}
But I receive the error A non well formed numeric value encountered.
How to achieve this? Having in mind that I receive the value of the $value variable from the client, so, anything can be present here, but I just will pass it if aren't according with if($value_formated <= $another_value).
,to a dot.. You are comparing10,20 <= 20.40