number_format($number, 2, '.', '');
Read more at PHP.net. You don't need to determine if a number is an integer or not -- as long as it's a number, it will be formatted to two decimal places.
If you'd like the thousands separator, change the last parameter to