pattern.php

 https://programmingwithvishal.com/demo/pattern/



<?php
//output
// 1
// 22
// 333
// 4444
// 55555
   
//    for($i = 1;$i<=5;$i++)
//     {
//         for ($j=0; $j < $i; $j++) { 
//             echo $i;
//         }
//         echo"<br>";
        
//     }


//output
// $$$$$
// $$$$
// $$$
// $$
// $
// for($i=5;$i>=1;$i--)
// {
//     for($j=1;$j<=$i;$j++)
//     {
//         echo"$";

//     }
//     echo "<br>";
// }




// output
//   *      
//  ***    
// *****  
// *******

$n = 4;
for($i =1;$i<=$n;$i++)
{
  
    for($j = 1;$j<=(2*$n)-1;$j++)
    {
        if($j>=$n-($i-1) && $j<=$n+($i-1)){
           
            echo "*";
        }
        else{
            echo "&nbsp&nbsp";
        }
      
    }
    echo "<br>";
}
?>

Comments

Popular posts from this blog

dompdf_index.php

user in rest flag api