Php program to alphabet triangle using range() method

A Php program to alphabet triangle using range() method. The range() function is a PHP built-in function that creates an array of elements of any kind, such as integers and alphabets, within a particular range (from low to high), i.e. the list’s first entry is considered low and the last element is considered high. array range is the syntax.

<?php 
$alpha = range('A', 'Z');
for($i=0; $i<5; $i++)
{
for($j=5; $j>$i; $j--)
{
echo $alpha[$i];
}
echo "<br>";
}
?>

 

Output:

AAAAA

BBBB

CCC

DD

E

What is range() function in php

The range() function returns an array with a specified number of entries. This function returns an array of elements arranged in ascending order from low to high. The range array will be from high to low if the low value is greater than the high parameter. The range() method in PHP is used to produce an array of elements of any type, such as integers or alphabets, within a particular range, where the first element of the list is considered low and the last element is considered high.

What is for loop in php and how to implement

A loop is used to repeatedly execute a set of statements until a certain condition is met. When showing numbers from 1 to 100, for example, you might wish to set the value of a variable to 1 and display it 100 times, raising its value by 1 with each loop iteration.

What is echo function in php

echo is a statement that displays the output of a command. echo() and echo can be used with or without parentheses. echo does not produce a result. In echo, several strings can be separated by a comma (,). The echo statement is quicker than the print statement.

What is dollar symbol in php programming language

$x is a regular variable with the name x that can hold any type of value, including strings, integers, floats, and so on. The $x variable is a reference variable that stores a value that may be accessed by typing $ before the $x value.