I have a form that uses jQuery to calculate totals before submission. It sends the total along with the currency symbol to the form handling script. This is generating some
Warning: A non-numeric value encountered
messages, so I have been using str_replace
. However, the following code is still generating the errors. It works everywhere else apart from this one section of code and I cannot find a solution. Could anyone help with some advice.
function netprice() {
$vatrate = 1.2;
$gross = str_replace('£','',$_POST['unit_Price']);
$net = round(($gross / $vatrate) , 2);
if (empty($gross)) {
echo"-";
}else{
echo $net;
}
}