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.
Using FTP and PHP to get an array of file details such as size and…
Creating and using Laravel form requests to create cleaner code, separation and reusability for your…
Improving the default Laravel login and register views in such a simple manner but making…
Laravel validation for checking if a field value exists in the database. The validation rule…