How To Make The Star Triangle In Php?
November 26, 2012
It is very easy to make a STAR Triangle in php. This is a type of matrix in which we can print rows and columns. You can make the STAR triangle by using (for loop) or (foreach) loop in php. ‘For’ or ‘foreach’ loop make it very easy in to make STAR Triangle. This can improve the logic of Fresher. Check below the programming syntax in front of output:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
<?php for($i=0;$i<=5;$i++){ for($j=5-$i;$j>=1;$j--){ echo "* "; } echo "<br>"; } ?> |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
</pre> <?php for($i=0;$i<=5;$i++){ for($j=1;$j<=$i;$j++){ echo "* "; } echo "<br>"; } ?> |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
<?php for($i=0;$i=$i;$k--){ echo " "; } for($j=1;$j<=$i;$j++){ echo "*"." "; } echo "<br>"; }?> |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
<?php for($i=5;$i-->=0;$i--){ for($k=5;$k>=$i;$k--){ echo " "; } for($j=1;$j<=$i;$j++){ echo "* "; } echo "<br>"; } ?> |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
<?php for($i=0;$i<=6;$i++){ for($k=6;$k>=$i;$k--){ echo " "; } for($j=1;$j<=$i;$j++){ echo "* "; } echo "<br>"; } for($i=5;$i>=1;$i--){ for($k=6;$k>=$i;$k--){ echo " "; } for($j=1;$j<=$i;$j++){ echo "* "; } echo "<br>"; } ?> |
53 Comments
Good Article for learner. Great help. Thanks
How To Make The Star Triangle In Php?| .powerfaq.com | Power FAQ
How to make following star pattern in php???
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
=$i;$k–){
echo ” “;
}
for($j=1;$j<=$i;$j++){ echo "* "; } echo "
“;
}
for($i=3;$i>=1;$i–){
for($k=4;$k>=$i;$k–){
echo ” “;
}
for($j=1;$j<=$i;$j++){ echo "* "; } echo "
“;
}
?>
Please try above code, Hope you will enjoy!!!
*
*
* *
* *
* * *
* *
* *
*
*
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
How to make that
1
121
12321
1234321
Please check below:
Numeric Polygon
http://www.powerfaq.com/make-numeric-polygon-php/
How can we print this pattern in php.
– – – – * * * * – – – –
– – – * * * * * * – – –
– – * * * * * * * * – –
– * * * * * * * * * * –
– – * * * * * * * * – –
– – – * * * * * * – – –
– – – – * * * * – – – –
Please check these urls:
Star Polygon:
http://www.powerfaq.com/make-star-polygon-php/
Numeric polygon with odd numbers:
http://www.powerfaq.com/php-code-numeric-polygon-with-odd-numbers/
for ($e=1; $e= 1; $d– )
{
echo ‘- ‘;
}
for($p =0; $p = 1; $d– )
{
echo ‘- ‘;
}
echo “”;
}
for($cc=2; $cc<=4; $cc++ )
{
for($aa=1; $aa = 2; $dd– )
{
echo “* “;
}
for($aa=1; $aa <=$cc; $aa++ )
{
echo '- ';
}
echo "”;
}
1
11
121
1331
14641
161051
how to print
*
* *
* *
* *
*
how to print
*
* *
* *
* *
*
how to print
—-*
—* *
–* *
—* *
—-*
how to print
——*
—–* *
—-* –*
—-* *
—–*
**********
**** ****
*** ***
** **
* *
How can i do it
Please use this code
=$b-1; $c–){
if($c>=$b){
echo $s;
}
elseif($b != 1){
echo ” “;
}
}
for($d=5; $d>=$b; $d–){
echo $s;
}
echo “<br>”;
}
?>
How can we print this pattern in php.
555555555
5555555
55555
555
5
5
555
55555
5555555
555555555
did you check this ? http://www.powerfaq.com/how-to-print-a-numeric-pattern/
1 2
3 4
5 6
7 8
9 10
plz send me code for ths using for loop
Please try this code
$a; $b–){
if($b%2 == 0){
echo $b;
echo “<br>”;
}
}
}
?>
* * * * * * * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
How can we print this pattern in php.
input type value and then digits add and with answer
1 =1
1+2=3
1+2+3=6
1+2+3+4=10
1+2+3+4+5=15
…………………..
………………….
the end 99 value valid
please help me
thanks sir
Please check below link
http://www.powerfaq.com/how-to-add-digits-of-a-numeric-series/
<?php
for($i=1; $i<=9; $i++){
echo '’;
for($j=9; $j>=$i; $j–){
echo ‘ ‘;
}
$val = 0;
for($k=1; $k
<?php for($i=1; $i<=9; $i++){ echo '’;for($j=9; $j>=$i; $j–){echo ‘ ‘;}$val = 0;for($k=1; $k
how can we print like this pattern in php
1*
**2
3***
****4
5*****
1***23*******45*****
Please use following code
how tp print L as stars in php
1
21
321
4321
Please use following code
=1; $b–){
echo “$b”;}
echo “<br>”;
}
?>
How to print
1
21
321
4321
Please try this code
=1; $b–){
echo “$b”;}
echo “<br>”;
}
?>
How can I print this pattern in php.
–
—
—
—-
—–
——
——–
———-
and
|\
| \
| \
| \
| \
| _ _ _ \
How to print this pattern
*
***
*****
***
*
Please try following code
=1; $a–){
if($a%2 != 0){
for($b=5; $b>=$a; $b–){
echo $s;}
echo “<br>”;
}
}
for($a=2; $a<=5; $a++){ if($a%2 != 0){ for($b=5; $b>=$a; $b–){
echo $s;}
echo “<br>”;
}
}
?>
How to print ??
5
54
543
5432
54321
Please try following code
=1; $a–){
for($b=5; $b>=$a; $b–){
echo $b;}
echo “<br>”;
}
?>
How to print it?
***************************************
******************* *******************
****************** ******************
***************** *****************
**************** ****************
*************** ***************
************** **************
************* *************
************ ************
*********** ***********
********** **********
********* *********
******** ********
******* *******
****** ******
***** *****
**** ****
*** ***
** **
***************************************
Please use following code
=1; $c–){
if($c>=$b){
echo $s;
}
elseif($b<=19){ echo " "; } else{ echo $s; } } for($d=1; $d<=20; $d++){ if($b==20){ echo $s; } elseif($d<$b){ echo " "; } else{ echo $s; } } echo "<br>"; } ?>
How we print “N” in star pattern??
How to create this?
*
**
***
****
*****
******
*******
********
*********
**********
***********
Please check here https://www.powerfaq.com/how-to-make-the-star-triangle-in-php/
+
++
+++
++++
+++++
Please try this
*
* *
* * *
* * * *
* * * * *
* * * * * *
*
* *
* *
* *
* * * * *
How to print
6 5 4
3 2
1
*
* *
* * *
* * * *
* * * * *
any one please help to create this
*
*A*
*a*a*
*a*a*a*
*a*a*a*a*
*
**
***
****
*****