I am trying to make a program that gives an oputput like:
x
xx
xxx
xxxx
xxxxx
xxxx
xxx
xx
x
I have a similar program which is:
<?php
$n = 4;
$R[] = '*';
$w = 1;
for( $c=1; $c<=$n; $c++ ){
$R[] = '*'.str_repeat( '*',$w );
$w = $w+1;
}
print '<pre>'.implode( "\n",$R ).'</pre>';
?>
but i need to use a function and create an other loop for an easier code.
I also need to decrease it after 5th row.
thanx in advance…
1 Answer