how do I remove some numbers after the comma in PHP

2

How do I remove some numbers after the comma in PHP? ex: 25.52382832732732 ...  so I want it to stay only 25.52

    
asked by anonymous 01.07.2017 / 23:25

2 answers

2

This would be a solution

You use the round function that in the first parameter receives the number and in the second it receives the optional number of decimal digits to round with the default being 0

$valor = round(25.52382832732732, 2);
echo $valor;

font

    
01.07.2017 / 23:31
2

One of the ways to do this is with number_format , from this momentum:

number_format($valor, 2);
    
01.07.2017 / 23:37