I have $498000.88687688 in my bank account.
498,000.89
498 , 000 , 89
Problem: 549/16
Answer = 34.31
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../styles.css">
<title>Formatting Numbers in PHP</title>
</head>
<body>
<h1 class="lesson-h1">Formatting Numbers in PHP</h1>
<?php
$largeNumber = 498000.8868768765675675;
echo "<p> I have $" . $largeNumber . " in my bank account.</p>";
//number_format() will limit the deciamls of a value for you.
echo "<p>" . number_format($largeNumber, 2) . "</p>";
//Here we are controling the decimals and then which symbols show in the final number
echo "<p>" . number_format($largeNumber, 2, ' , ', ' , ') . "</p>";
function divide($num1, $num2){
$total = $num1 / $num2;
$result = number_format($total, 2);
return $result;
}
echo "<hr><p>Problem: 549/16</p>";
echo "<p>Answer = " . divide(549, 16) . "</p><hr>";
include('../show_code.php');
show_code('index.php');
?>
</body>
</html>