Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Jawaban Soal 1
- $x = 0;
- while(++$x <= 100)
- echo($x!=8 && $x!=9 && $x!=10 && $x!=12)?"$x,":"";
- /*Output
- 1,2,3,4,5,6,7,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,
- */
- ?>
- <br />
- <br />
- <?php
- //Jawaban Soal 2
- $nama = array("Anto","Hilmi","Khafindi","Faris");
- $rumah = array("Mlonggo","Bugel","Margoyoso","Wanusobo");
- echo "Nama = "; foreach ($nama as $value) {
- print "$value, ";
- }
- echo " <br /><br />Rumah " .$nama[1]. " ada di " .$rumah[1]. "<br /><br />";
- echo "Rumah = <br />";
- for ($x=0;$x<4;$x++)
- {
- print "$nama[$x] : $rumah[$x] <br />";
- }
- /*Output
- Nama = Anto, Hilmi, Khafindi, Faris,
- Rumah Hilmi ada di Bugel
- Rumah =
- Anto : Mlonggo
- Hilmi : Bugel
- Khafindi : Margoyoso
- Faris : Wanusobo
- */
- ?>
- <br />
- <br />
- <?php
- //Jawaban Soal 3
- function tampil_angka($param1,$param2) {
- for ($i = 1; $i <= $param1; $i++) {
- if (in_array($i, $param2)) continue;
- echo $i . ',';
- }
- }
- tampil_angka('100',array(8,9,10,12));
- /*Output
- 1,2,3,4,5,6,7,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,*/
- ?>
- <?php
- //Script By Bastomi Adi Nugroho @UNISNU JEPARA TIF
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement