Syntax:
while (condition){
// to do
}
<?php
$counter = 1;
while($counter <= 10){
echo "This is : " . $counter . "<br />";
$counter++;
}
?>
Output:
Another Example:
<table border="1">
<tr>
<td>No</td>
<td>Design</td>
</tr>
<tr>
<?php
$counter = 1;
while($counter <= 10){
$subCount = 1;
echo "<td>" . $counter . "</td><td>";
while ($subCount <= $counter){
echo "* ";
$subCount++;
}
echo "</td></tr>";
$counter++;
}
?>
</table>
Output
No comments:
Post a Comment