
Program sederhana ini sangat sering keluar ketika Anda akan di hadapkan dengan test coding.
langsung saja. Lihat kode program dibawah ini:
1. Output Segitiga Arah Ke Atas

<?php
$star=10;
for( $a=$star;$a>0;$a--){
for($i=1; $i<=$a; $i++){
echo " ";
}
for($a1=$star;$a1>=$a;$a1--){
echo"*";
}
echo"<br>";
}
?>
2. Output Setengah Segitiga Arah Ke Atas Sisi Kiri

<?php
$star=10;
for($a=$star;$a>0;$a--){
for($i=1; $i<=$a; $i++){
echo "  ";
}
for($a1=$star;$a1>=$a;$a1--){
echo"*";
}
echo"<br>";
}
?>
3. Output Setengah Segitiga Arah Ke Atas Sisi Kanan
<?php
$star=10;
for($a=$star;$a>0;$a--){
for($b=$star;$b>=$a;$b--){
echo "*";
}
echo "<br>";
}
?>
4. Output Segitiga Arah Ke Bawah

<?php
$star=10;
for($a=1; $a<=$star; $a++){
for($b=1; $b<=$a; $b++){
echo " ";
}
for($c=$star; $c>=$a; $c-=1){
echo "*";
}
echo "<br>";
}
?>
5. Output Setengah Segitiga Arah Ke Bawah Sisi Kiri

<?php
$star=10;
for($a=1; $a<=$star; $a++){
for($i=1; $i<=$a; $i++){
echo "  ";
}
for($c=$star; $c>=$a; $c-=1){
echo "*";
}
echo "<br>";
}
?>
6. Output Setengah Segitiga Arah Ke Bawah Sisi Kanan

<?php
$star=10;
for($a=1; $a<=$star; $a++){
for($c=$star; $c>=$a; $c-=1){
echo "*";
}
echo "<br>";
}
?>
7. Output Kombinasi Segitiga Pola Diamond Atau Belah Ketupat

<?php
$star=10;
for($a=1; $a<=$star; $a++){
for($b=$star; $b>=$a; $b-=1){
echo " ";
}
for($c=1; $c<=$a; $c++){
echo "*";
}
echo "<br>";
}
for($a=1; $a<=$star; $a++){
for($b=1; $b<=$a; $b++){
echo " ";
}
for($c=$star; $c>=$a; $c-=1){
echo "*";
}
echo "<br>";
}
?>

nice