This sounds suspiciously like homework to me. Oh well, if it is it's no matter it'll only screw yourself up. :evilgrin:
<?php
function triangle($depth) {
static $grow=true;
echo(str_repeat('-', $depth)."\n");
if($grow && $depth<10) {
triangle($depth+1);
} elseif($grow || $depth>0) {
$grow=false;
triangle($depth-1);
} else {
return;
}
}
triangle(0);
?>