Nested PHP if and if else statements can be confusing however if following the correct formatting and PHP basics they can be a very useful piece of code.
In the example below i define $var as 88 and do some comparisons to find where it sits in between higher and lower numbers.
$var = 88;
if ($var >= 100) {
if ($var <= 200) {
echo "Var is in between 100 and 200";
} else if ($var <= 500) {
echo "Var is in between 200 and 500";
} else if ($var <= 900) {
echo "Var is in between 500 and 900";
}
} else if ($var <= 100) {
if ($var >= 50) {
if ($var <= 90) {
if ($var >= 80) {
echo "Var in between 80 and 90";//this will be what gets echoed
}
else if ($var >= 89) {
echo "Var in between 89 and 90";
}
}
}
}
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Some early September spring shots from a bushwalk, It is still too early for wildflowers.
I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…
If you ever needed a simple solution in Laravel to delete an entire directory and…
How to enforce only one user to register or be registered in a Laravel web…