What is the best way to conditionally set a variable based on a range of values in PHP?

When you need to conditionally set a variable based on a range of values in PHP, you can use an if-else statement or a switch statement to check the value against the range conditions and set the variable accordingly. This allows you to assign different values to the variable based on the specific range that the input falls into.

$value = 75;

if ($value < 50) {
    $variable = "Low";
} elseif ($value >= 50 && $value < 100) {
    $variable = "Medium";
} else {
    $variable = "High";
}

echo $variable; // Output: Medium