while statement

No swearing, link posting, adult oriented, or illegal posts.
Post Reply
Chris
Site Admin
Posts: 205
Joined: Sat Jan 11, 2020 12:44 am

while statement

Post by Chris »

Much like the if statement, it will check if one item equals the other item.

example 1:
while($first==$second)
{
echo"The two items are the same";
}

You can also check to see if they do not equal, or greater/less to each other.

example 2:
while($first!=second")
{
echo"The two are not the same";
}

With using the while statement, the best usage that I use it for is when I am counting numbers. Example 3 will count the numbers until the two items become equal.

example 3:
$count="0";$target="15";
while($count != $target)
{
$count=$count+"1";
}

This will repeat the $count plus 1 until $count =15.
Support these areas by allowing Advertisements! :geek:
Post Reply