Showing posts with label for loop. Show all posts
Showing posts with label for loop. Show all posts

Monday, 1 December 2014

For Loop in Php

Structure of the Problem Requirements 

In this problem we will discuss about for loop in Php. Loops are used to repeat the same pattern as per user requirements . But in our case we just initialize a number from 0 and tend it to 40. we have implement four for loops and in every for loops ten numbers are increases. Here is the source code of this example which help you in better understanding .


SOURCE CODE


<html>
<head>
<title>For Loops Php </title>
</head>
<body>
<?php
echo "<br />";
echo " For Loop _ 1 : ";
echo "<br />";
echo "<br />";
for ($Numbers=0; $Numbers <= 10; $Numbers++) {
echo $Numbers . ", ";
}
echo "<br />";
echo "<br />";
echo " For Loop _ 2 : ";
echo "<br />";
echo "<br />";
for ($Numbers=10; $Numbers <= 20; $Numbers++) {
echo $Numbers . ", ";
}
echo "<br />";
echo "<br />";
echo " For Loop _ 3 : ";
echo "<br />";
echo "<br />";
for ($Numbers=20; $Numbers <= 30; $Numbers++) {
echo $Numbers . ", ";
}
   echo "<br />";
echo "<br />";
echo " For Loop _ 4 : ";
echo "<br />";
echo "<br />";
for ($Numbers=30; $Numbers <= 40; $Numbers++) {
echo $Numbers . ", ";
}
?>
</body>
</html>

OUTPUT OF THE PROGRAM

For loop
For loop in php