Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- latihan8.html
- <html>
- <body>
- Mengurutkan Array (Terbalik):<br><br>
- <form action="latihan8.php" method="post">
- Input 1 :<input type="text" name="input1"/><br>
- Input 2 :<input type="text" name="input2"/><br>
- Input 3 :<input type="text" name="input3"/><br>
- Input 4 :<input type="text" name="input4"/><br>
- Input 5 :<input type="text" name="input5"/><br><br>
- <input type="submit" value="Urutkan"/>
- </form>
- </body>
- </html>
- latihan8.php
- <?php
- function urutbalik()
- {
- $input1=$_POST["input1"];
- $input2=$_POST["input2"];
- $input3=$_POST["input3"];
- $input4=$_POST["input4"];
- $input5=$_POST["input5"];
- $inputs = array("$input1", "$input2", "$input3", "$input4", "$input5");
- if (is_numeric ($input1) && is_numeric ($input2) && is_numeric ($input3) && is_numeric ($input4) && is_numeric ($input5))
- {
- rsort($inputs);
- foreach ($inputs as $key => $val)
- {
- $key1=$key+1;
- echo "$key1. $val<br>";
- }
- }
- else
- {
- echo "Seluruh Input Harus berupa Angka";
- }
- }
- ?>
- <html>
- <body>
- Hasil yang Telah Diurutkan :<br><br>
- <?php
- urutbalik();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement