Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Kasus 3 (M. Hafidz Fadillah - XI RPL 2)</title>
- <style type="text/css">
- body{
- background-color: blanchedalmond;
- }
- input.button{
- color: black;
- background: white;
- border: 2px darkgray outset;
- padding: 5px 20px;
- font-size: 14px;
- }
- input.button:hover{
- color: white;
- background: black;
- }
- </style>
- </head>
- <body>
- <h1>Hitung Jumlah Huruf</h1>
- <form name="" id="" method="post" action="">
- <p>Masukkan Kalimat
- <input type="text" name="kalimat">
- <input type="radio" name="huruf" value="a">a
- <input type="radio" name="huruf" value="i">i
- <input type="radio" name="huruf" value="u">u
- <input type="radio" name="huruf" value="e">e
- <input type="radio" name="huruf" value="o">o
- <input class="button" type="submit" name="submit" value="Hitung">
- </p>
- <?php
- $kalimat = $_POST['kalimat'];
- $huruf = $_POST['huruf'];
- $a=0;
- $jumlah=0;
- while ($a <= strlen($kalimat)) {
- if ($kalimat[$a] == $huruf) {
- $jumlah++;
- }
- $a++;
- }
- ?>
- <?php
- echo "<p>Jumlah Huruf '$huruf' pada kalimat '$kalimat' adalah $jumlah</p>";
- ?>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement