Write a PHP code to print following number pattern:
123
456
789
Answers were Sorted based on User's Feedback
Answer / sheetal
<?php
$k=1;
while($k<9)
{
for($i=1;$i<=3;$i++)
{
echo $k;
$k++;
}
echo "</br>";
}
?>
Is This Answer Correct ? | 7 Yes | 0 No |
<? php
$i=1;
while($i<=3)
{
echo $i;
$i++;
}
echo "<br>" ;
$j=$i;
while($j<=6)
{
echo $j;
$j++;
}
echo "<br>" ;
$k=$j;
while ($k<=9)
{
echo $k;
$k++;
}
echo "<br>" ;
? >
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / sam
<?php
$num = "";
for($i = 1; $i<=9; $i++ )
{
if($i%3 == 1)
{
echo "<br />";
}
echo $i;
}
?>
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / ronak sharma
<?php
$count=0;
for($i=1;$i<=3;$i++)
{
for($j=1;$j<=3;$j++)
{
$count++;
echo $count;
}
echo "<br>";
}
?>
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / rajendra
<?php
$num = "";
for($i=1;$i<=9;$i++) {
$num .= $i;
if($i%3==0){
$num .="<br />";
}
}
echo $num;
?>
Is This Answer Correct ? | 1 Yes | 1 No |
What do you mean by core php?
What type of headers have to be added in the mail function to attach a file?
How to remove html tags from data in php?
What is register_globals in php?
6 Answers Castling IT, HCL, Intel Soft Solutions, Millennium,
Name some of the constants in php and their purpose.
What is a php web application?
What is the difference between get and post method in php?
How do I stop a php script?
Where are the persistent cookies stored on your computer?
What are the differences between PHP3 and PHP4 versions?
How can we display the output directly to the browser?
How does php sessions work?