If the input is 2, the output should be:
if it is 3 it should output:x
xx
This is what i got so far...x
xx
xxx
Code: Select all
<?php
$input = 3;
$i = 1;
$x = "x";
while ($i <= $input) {
echo $x."<br>";
$i++;
}
?>Moderator: General Moderators
if it is 3 it should output:x
xx
This is what i got so far...x
xx
xxx
Code: Select all
<?php
$input = 3;
$i = 1;
$x = "x";
while ($i <= $input) {
echo $x."<br>";
$i++;
}
?>Code: Select all
$input = 5;
$x = 'x';
for ($i = 0; $i < $input; $i++) {
echo $x.'<br>';
$x .= 'x';
}Thanks a lot!DigitalMind wrote:Code: Select all
$input = 5; $x = 'x'; for ($i = 0; $i < $input; $i++) { echo $x.'<br>'; $x .= 'x'; }