Trying to figure out how user filters php in a smart way
//Do sanization of user input
//$_POST['amount_ecb'] can be 77,7 or 77.7
$amount = filter_input(INPUT_POST, 'amount_ecb',
FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
if the displayed value is 77.7, it sets the amount correctly, but if the user dials a semicolon instead of a period (for example, 77.7) $amountreturns 77
I want him to return 77.7 in both cases. Can this be solved using filters?
UPDATE
After feedback (sent reply), I still have the same problem:
Using
$_POST['amount_ecb'] = str_replace(',', '.', $_POST['amount_ecb']);
before
It was he who returned
$ _ POST Object
array (size=5)
'amount_ecb' => string '77.7' (length=4)
'from_ecb' => string 'GBP' (length=3)
'to_ecb' => string 'SEK' (length=3)
'submit' => string 'Calculate currency' (length=18)
'result_decimals' => string '4' (length=1)
$ amount
string '777' (length=3)
source
share