<?php
// define the plans with their premiums
$plan1 = 1000;
$plan2 = 1500;
// get the user's age and sex from the form
$age = $_POST['age'];
$sex = $_POST['sex'];
// calculate the premium based on the user's age and sex
if ($sex == 'male') {
if ($age < 25) {
$premium = 2000;
} else {
$premium = 1500;
}
} else {
if ($age < 25) {
$premium = 1500;
} else {
$premium = 1000;
}
}
// check if the multiply checkbox was selected
if (isset($_POST['multiply'])) {
// multiply the premium by 1.4 if the checkbox was selected
$premium *= 1.4;
}
// display the table comparing the premiums for the two plans
echo '<table>';
echo '<tr><th>Plan</th><th>Premium</th></tr>';
echo '<tr><td>Plan 1</td><td>$' . $plan1 . '</td></tr>';
echo '<tr><td>Plan 2</td><td>$' . $plan2 . '</td></tr>';
echo '<tr><td>Your Plan</td><td>$' . number_format($premium, 2) . '</td></tr>';
echo '</table>';
// display the checkbox for the user to opt-in to multiply the premium
echo '<form method="post">';
echo '<label><input type="checkbox" name="multiply" value="1"> Multiply by 1.4</label><br>';
echo '<input type="submit" value="Calculate Premium">';
echo '</form>';
?>
str_replace(‘,’, ”, $plan1)
This replaces any comma in the string value of $plan1 with an empty string, effectively removing it. For example, if $plan1 is “1,234.56”, this will become “1234.56”.