Number Format with Decimals php

0

I do the following filter at the value sent 3.5

$prd_PorcentajeRF = filter_input(INPUT_POST, 'prd_PorcentajeRF', 
FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);

And after the filter shows 4 or 35, how can I fix it? Thanks

    
asked by Juan Carlos 25.05.2018 в 23:00
source

2 answers

0

You can use the php function number_format to convert the number with points to decimals.

example:

$numero = 3.5;
$numero_coma = number_format($numero);

exit:

  

3,5

    
answered by 26.05.2018 в 00:01
0

The filter is correct, the problem was in the database where the data type was as Decimal 10,0, change it to 12,2 and the value is already displayed correctly. Thanks for your comments.

    
answered by 26.05.2018 в 10:37