Last active
May 29, 2016 16:03
-
-
Save afzafri/ab0026a0fb3c21e751d15da057920630 to your computer and use it in GitHub Desktop.
kira nombor setiap 2 nombor dan display
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Check Nombor</title> | |
</head> | |
<body> | |
<form action="nombor.php" method="get"> | |
<b>Masukkan 4 nombor (space) : </b><br><br> | |
<input type="text" name="no"> | |
<input type="submit" name="submit" value="Kira"> | |
</form> | |
<?php | |
if(isset($_GET['submit'])) | |
{ | |
$no = $_GET['no']; | |
$arr = explode(" ",$no); | |
$arr2 = array(); | |
$arr3 = array(); | |
echo "<b>Result:</b><br><br>"; | |
echo "<div align='right' style='border:1px solid black;width:200px'>"; | |
//display line pertama | |
for($i=0;$i<4;$i++) | |
{ | |
echo $arr[$i] . " "; | |
} | |
echo "<br>"; | |
//kira dan display untuk line pertama | |
for($i=0;$i<4;$i++) | |
{ | |
if(($i+1) < 4) | |
{ | |
$calc = ($arr[$i] + ($arr[$i+1])) % 10; | |
echo $calc . " "; | |
$arr2[$i] = $calc; | |
} | |
} | |
echo "<br>"; | |
//kira dan display untuk line kedua | |
for($i=0;$i<3;$i++) | |
{ | |
if(($i+1) < 3) | |
{ | |
$calc = ($arr2[$i] + ($arr2[$i+1])) % 10; | |
echo $calc . " "; | |
$arr3[$i] = $calc; | |
} | |
} | |
echo "<br>"; | |
//kira dan display untuk line ketiga | |
for($i=0;$i<2;$i++) | |
{ | |
if(($i+1) < 2) | |
{ | |
$calc = ($arr3[$i] + ($arr3[$i+1])) % 10; | |
echo $calc . " "; | |
} | |
} | |
echo "</div>"; | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment