Skip to content

Instantly share code, notes, and snippets.

@ahmadkarlam
Last active August 29, 2015 14:06
Show Gist options
  • Save ahmadkarlam/cd0667b0798b298e026b to your computer and use it in GitHub Desktop.
Save ahmadkarlam/cd0667b0798b298e026b to your computer and use it in GitHub Desktop.
Logic Alif
<?php
$angka = 35;
for ($i = 1; $i <= $angka; $i++)
{
if ($i == 1)
{
for ($a = 1; $a <= $angka; $a++)
{
if ($a == $angka)
{
echo '<span style="color:red">8</span><br/>';
}
elseif ($a <= ceil($angka/2))
{
echo '<span style="color:red">8</span>';
}
else
{
echo "8";
}
}
}
if ($i < ceil($angka / 2) and $i != 1)
{
for ($a = 1; $a <= $angka; $a++)
{
if ($a == ceil($angka/2))
{
echo '<span style="color:red">8</span>';
}
elseif ($a == $angka)
{
echo '<span style="color:red">8</span><br />';
}
else
{
echo '8';
}
}
}
if ($i > ceil($angka / 2) and $i != $angka)
{
for ($a = 1; $a <= $angka; $a++)
{
if ($a == ceil($angka/2))
{
echo '<span style="color:red">8</span>';
}
elseif ($a == 1)
{
echo '<span style="color:red">8</span>';
}
elseif ($a < ceil($angka/2))
{
echo '8';
}
elseif ($a > ceil($angka/2))
{
if ($a == $angka)
{
echo '8<br />';
}
else
{
echo '8';
}
}
}
}
if ($i == ceil($angka/2))
{
for($a = 1; $a <= $angka; $a++)
{
if ($a != $angka)
{
echo '<span style="color:red">8</span>';
}
elseif ($a == $angka)
{
echo '<span style="color:red">8</span><br />';
}
}
}
if ($i == $angka)
{
for ($a = 1; $a <= $angka; $a++)
{
if ($a == 1)
{
echo '<span style="color:red">8</span>';
}
elseif ($a >= ceil($angka/2))
{
echo '<span style="color:red">8</span>';
}
else
{
echo '8';
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment