How to print alphabet latters In Php?

It is very easy to print alphabet latter in php. This is a type of matrix in which we can print rows and columns. You can make the alphabet latter using for loop and if condition in php. This can improve the logic of Fresher. Check below the programming syntax in front of output:

<?php
for ($i=0; $i<=6; $i++)
{
  for ($j=0; $j<=6; $j++)
	{
        if ((($j == 1 || $j == 4)
		&&  $i != 0) || (($i == 0 || $i == 3)
		&&  ($j > 1  &&  $j < 4)))
		{ echo "*";    
        } else { 
            echo "&nbsp;&nbsp;";  
		}
	}        
  echo "<br/>";
}?>
Alphabet latter A
<?php
for ($i=0; $i<7; $i++)
{
  for ($j=0; $j<=7; $j++)
	{
      if ($j == 1 || (($i == 0 || $i == 3 || $i == 6)
	&&  ($j < 5  &&  $j > 1))
	|| ($j == 5  &&  ($i != 0  &&  $i != 3  &&  $i != 6)))
            echo "*";    
        else  
            echo "&nbsp;&nbsp;";     
	}        
  echo "<br>";
}?>
Alphabet latter B
<?php
for ($i=0; $i<7; $i++)
{
  for ($j=0; $j<=7; $j++)
	{
     if (($j == 1  &&  ($i != 0  &&  $i != 6))
	|| (($i == 0 || $i == 6)
		&&  ($j > 1  &&  $j < 5))
		|| ($j == 5  &&  ($i == 1 || $i == 5)))
            echo "*";    
        else  
            echo "&nbsp;&nbsp;";     
	}        
  echo "<br>";
}?>
Alphabet latter C
<?php
for ($i=0; $i<7; $i++)
{
  for ($j=0; $j<=7; $j++)
	{
     if ($j == 1 || (($i == 0 || $i == 6)
	&& ($j > 1 && $j < 6))
	|| ($i == 3 && $j > 1 && $j < 5))
            echo "*";    
        else  
            echo "&nbsp;&nbsp;";     
	}        
  echo "<br>";
}?>
Alphabet latter D
<?php
for ($i=0; $i<7; $i++)
{
  for ($j=0; $j<=7; $j++)
	{
     if ($j == 1 || (($i == 0 || $i == 6)
	&& ($j > 1 && $j < 6))
	|| ($i == 3 && $j > 1 && $j < 5))
            echo "*";    
        else  
            echo "&nbsp;&nbsp;";     
	}        
  echo "<br>";
}?>
Alphabet latter E
<?php
for ($i=0; $i<7; $i++)
{
  for ($j=0; $j<=7; $j++)
	{
     if ($j == 1 || ($i == 0
		&& ($j > 1 && $j < 6))
		|| ($i == 3 && $j > 1 && $j < 5))
            echo "*";    
        else  
            echo "&nbsp;&nbsp;";     
	}        
  echo "<br>";
}?>
Alphabet latter F

Leave a Reply