Skip to content

Instantly share code, notes, and snippets.

@uyab
Created March 17, 2017 06:24
Show Gist options
  • Save uyab/efe427fd711806e64a6400c088dff4c5 to your computer and use it in GitHub Desktop.
Save uyab/efe427fd711806e64a6400c088dff4c5 to your computer and use it in GitHub Desktop.
Print bilangan ganjil genap
<?php
$ganjil = $genap = [];
foreach (range(1, 100) as $angka) {
if ($angka % 2 == 0) {
$genap[] = $angka;
} else {
$ganjil[] = $angka;
}
}
echo 'List Bilangan Genap';
echo "<br>";
echo implode("<br>", $genap);
echo "<br>";
echo 'List Bilangan Ganjil';
echo "<br>";
echo implode("<br>", $ganjil);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment