ad

Friday, May 31, 2024

php program to print diamond pattern

  

php program to print diamond pattern

php program to print diamond pattern


php program to print diamond pattern

Example:-

<?php
echo "<pre>";
for($i=1;$i<8;$i++)
{
    for($j=$i; $j<8;$j++)
    echo "&nbsp;&nbsp;";
for($j=2*$i-1;$j>0;$j--)
echo("&nbsp;*");
echo"<br>";
}
$n =8;
for($i=8;$i>0;$i--){
    for($j=$n-$i;$j>0;$j--)
    echo "&nbsp;&nbsp;";
 for($j=2*$i-1;$j>0;$j--)
 echo ("&nbsp;*");
echo "<br>";

}
echo"</pre>";
?>

 php program to print diamond pattern

Output :-
php program to print diamond pattern


Related Post :-

php for loop

php program to print half diamond pattern

 php program to print half diamond pattern

php program to print half diamond  pattern

php program to print half diamond  pattern

Example :-

<?php
for($i=5;$i>=1;$i--)
{
    if($i%2!=0)
    {
        for($j=5;$j>=$i;$j--)
        {
        echo "*";

    }
  echo"<br>";
}
}
for($i=2;$i<=5;$i++)
{
    if($i%2!=0)
    {
        for($j=5;$j>=$i;$j--)
        {
            echo "*";
        }
        echo "<br>";
    }
}
?>

php program to print half diamond  pattern

Output:-

php program to print half diamond  pattern



Related Post :-

php program to print triangle pattern

php array types

php program to print increasing triangle

php program to print increasing triangle 


php program to print increasing triangle


php program to print increasing triangle  

Example :-

<?php
for($i=0;$i<=5;$i++){
for($j=1;$j<=$i;$j++){
echo "*";
}
echo '<br>';
}
?>

php program to print increasing triangle  

Output:-

php program to print increasing triangle


php program to print increasing triangle 

Example :- 

<?php
for($i=0;$i<=5;$i++){
for($j=1;$j<=$i;$j++){
echo "A";
}
echo '<br>';
}
?>

php program to print increasing triangle  

Output:-

right half pyramid in php program,php program to print increasing triangle,


Related Post:-

html datetime picker

html form input type

how to create contact form html and css

php program to print hourglass star pattern

Program to print left pascal star pyramid pattern in php

left pascal star pattern in php

 left pascal star pattern in php

Example :-

<?php
    $size = 5;
   
    for ($i = 1; $i <= $size; $i++) {
        for ($j = 0; $j < $size - $i; $j++) {
            echo "&nbsp;&nbsp;";
        }
        for ($k = 0; $k < $i; $k++) {
            echo "*";
        }
        echo "<br>";
    }
    for ($i = 1; $i <= $size - 1; $i++) {
        for ($j = 0; $j < $i; $j++) {
            echo "&nbsp;&nbsp;";
        }
        for ($k = 0; $k < $size - $i; $k++) {
            echo "*";
        }
        echo "<br>";
    }
?>
left pascal star pattern in php

Output:-

left pascal star pattern in php


left pascal star pattern in php

Example :-

<?php
    $size = 5;
   
    for ($i = 1; $i <= $size; $i++) {
        for ($j = 0; $j < $size - $i; $j++) {
            echo "&nbsp;&nbsp;";
        }
        for ($k = 0; $k < $i; $k++) {
            echo "b";
        }
        echo "<br>";
    }
    for ($i = 1; $i <= $size - 1; $i++) {
        for ($j = 0; $j < $i; $j++) {
            echo "&nbsp;&nbsp;";
        }
        for ($k = 0; $k < $size - $i; $k++) {
            echo "b";
        }
        echo "<br>";
    }
?>

left pascal star pattern in php

Program to print inverted Pyramid star pattern in php

Inverted Pyramid star pattern in php

 Inverted Pyramid star pattern in php

Example :-

<?php
echo "<pre>";
$n =10;
for($a=10; $a>0;$a--)
{
  for($b=$n-$a; $b>0; $b--)
  echo "&nbsp;&nbsp;";
for($b=2*$a-1; $b>0; $b--)
echo "&nbsp;*";
//change only  echo ""; value
    //for example :- 1,d,4,h,9,...etc
echo"<br>";
}
echo"</pre>";
?>

 Inverted Pyramid star pattern in php 

Output :-

inverted Pyramid star pattern in php

2] Inverted Pyramid star pattern in php

Example :-

<?php
echo "<pre>";
$n =10;
for($a=10; $a>0;$a--)
{
  for($b=$n-$a; $b>0; $b--)
  echo "&nbsp;&nbsp;";
for($b=2*$a-1; $b>0; $b--)
echo ("&nbsp;A");
//change only  echo ""; value
    //for example :- 1,d,4,h,9,...etc
echo"<br>";
}
echo"</pre>";
?>

 Inverted Pyramid star pattern in php 

Output :-

inverted Pyramid star pattern in php


Related Post :-

reverse right half pyramid in php

square pattern in php

PHP Program to Print Alphabet Pattern H

PHP Program to print Alphabet Pattern B

 php program to print alphabet pattern j

 php program to print alphabet pattern l