What's the correct way to round a PHP string to two decimal places?
$number = "520"; // It's a string from a database
$formatted_number = round_to_2dp($number);
echo $formatted_number;
The output should be 520.00;
How should the round_to_2dp() function …
What is the simplest most basic way to find out if a number/variable is odd or even in PHP?
Is it something to do with mod?
I've tried a few scripts but.. google isn't delivering at the moment.
PHP - Is there a quick, on-the-fly method to test for a single character string, then prepend a leading zero?
Example:
$year = 11;
$month = 4;
$stamp = $year.add_single_zero_if_needed($month); // Imaginary function
echo $stamp; // 1104