Q:

Print a sequence of letters

How do I print a sequence of letters with PHP, without using 'for'? It needs to be something like this:

I have a code like this:
<?php

$a = 'a';
$n = 50;
$i = 0;
$k = 0;

while ( $i < $n ) {
    echo $a." ".'<p></p>';
    for ($k =0; $k<=$i; $k++) { 
        echo $a." ";
    }
    $i++;
}
?>

But I don't need 'for', maybe something with 'while', 'if' or 'foreach'.
Ideas?

A:

One option could be to use a second while loop:
$a = 'a';
$n = 50;
$i = 0;

while ($i < $n) {
    $k = -1;
    $str = "";
    while ($k < $i) {
        $str .= " $a";
        $k++;
    }
    echo "$str<br>";
    $i++;
}

Php demo
Another option could be using str_repeat
while ( $i < $n ) echo str_repeat($a, ++$i) . "<br>";

Php demo

