So I got asked to output result like this in object oriented way.
Code: Select all
*
**
***
****My last minute code
Code: Select all
class stars {
var $star;
var $max;
function throwStars(){
for($i=0; $i<=$this->max; $i++){
for($a=$i; $a<$this->max; $a++){
echo $this->star;
}
echo '<br />';
}
}
}
$test = new stars;
$test->star='a';
$test->max=3;
$test->throwStars();Code: Select all
aaa
aa
a