Print Alphabet Pattern in PHP
Advertisements
Print Alphabet Pattern in PHP
For print this type of pattern you need to follow same concept of c programming only change syntax.
Print Alphabet Pattern in PHP
<?php
$ascii_val = ord("a");
for($i=$ascii_val;$i<$ascii_val+26;$i++)
{
echo chr($i)." ";
}
?>
Output
a b c d e f g h i j k l m n o p q r s t u v w x y z
Print Alphabet Pattern in PHP
<?php
$ascii_val = ord("a");
for($i=$ascii_val;$i<$ascii_val+26;$i++)
{
echo chr($i)."</br>";
}
?>
Output
a b c d e f g h i j k l m n o p q r s t u v w x y z
Print Alphabet Pattern in PHP
<?php
$alphas = range('A', 'Z');
foreach($alphas as $value)
{
echo $value."<br>";
}
?>
Output
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Print Alphabet Pattern in PHP
<?php
$letters = range('A', 'Z');
for($i=0; $i<5; $i++)
{
for($j=5; $j>$i; $j--)
{
echo $letters[$i];
}
echo "<br>";
}
?>
Output
AAAAA BBBB CCC DD E
Google Advertisment
