Friday, June 16, 2017

Time saver - Quick fix for non working round() function in PHP

If there are some problems with rounding floats with round() function in PHP, such as too long decimal string, we can safely replace it with function number_format().

For example:

$rounded=round($x, 2);

can be replaced with:

$rounded=number_format($x,2);

No comments:

Post a Comment

Ubuntu 12.04, 14.04, 16.04 - auto start an app or script before login

To run a command or application at startup, even before the user has logged in, you can use this file: /etc/rc.local The commands entered...