Sep 5, 2018 · 1 min read
Sintaks Bintang PHP LOOPING
<h1>BINTANG</h1><br>
<form action=”” method=”GET”>
Tinggi : <input type=”text” name=”tinggi”><br>
<input type=”submit” name=”submit” value=”Buat”>
</form>
<?php
if (isset($_GET[“submit”])) {
$x = $_GET[“tinggi”];
for ($i=1;$i<=$x;$i++) {
for ($j=1;$j<=($x*2);$j++) {
if ($i==1 && $j==$x) {
echo “*”;
}
else if ($i>1 && $j==($x-$i+1) || $j==($x+$i-1)) {
echo “*”;
}
else
echo “ ”;
}
echo “<br>”;
}
}
?>