I am getting 6 decimal places for when extracting insights from Facebook Api using the below command. Can someone please let me know how can I modify this command to get only 1 decimal place.
echo '<td>'.$insight->cpm. '</td>';
Use round
:
Returns the rounded value of val to specified precision (number of digits after the decimal point).
echo '<td>' . round($insight->cpm, 1) . '</td>';
you should format the number first, as per requirement-
number_format($insight->cpm,1)
It will return string value containing one decimal place.
round($insight->cpm,1);
It will return float value containing one decimal place.