The if statement executes some code if a condition is true .
for (init number; test number; increment number)
{
code to be executed;
}
<?php
for ($x = 0; $x <= 10; $x++) {
echo "The number is: $x
";
}
?>
The foreach loop used only print arrays values , and is used to loop through each key/value pair in an array.
foreach ($array as $value){
code to be executed;
}
<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as $value) {
echo "$value
";
}
?>
Learn PHP If-else Conditions: We have the following conditional statements in PHP language
Learn PHP loops: For loops execute the code number of times.
PHP Form Submission: For post data superglobals $_GET and $_POST are used in php.
Learn PHP array: An array stores multiple values in one single variable