while - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of while.php
- <!DOCTYPE html>
- <html>
- <head>
- <title>Studi Kasus While</title>
- <style type="text/css">
- body{
- background-color: #f2665c;
- font-family: cursive;
- }
- button{
- background-color: red;
- color: white;
- border: 1px solid black;
- }
- </style>
- </head>
- <body>
- <h1>
- Hitung jumlah huruf</h1>
- <br>
- <form method="POST" action="">
- <table>
- <tr>
- <td>Masukkan Kalimat</td>
- <td><input type="text" name="nama"></td>
- <td><input type="radio" name="vokal" value="a">a</td>
- <td><input type="radio" name="vokal" value="i">i</td>
- <td><input type="radio" name="vokal" value="u">u</td>
- <td><input type="radio" name="vokal" value="e">e</td>
- <td><input type="radio" name="vokal" value="o">o</td>
- <td><button type="submit">Hitung</button></td>
- </tr>
- </table>
- </form>
- <?php
- $vokal = $_POST['vokal'];
- $nama = $_POST['nama'];
- $i = 0;
- $jmlvokal = 0;
- while ($i < strlen($nama)) {
- if ($nama[$i] == $vokal) {
- $jmlvokal++;
- }
- $i++;
- }
- echo <<<eee
- Jumlah $vokal di <b>$nama</b> adalah $jmlvokal
- eee;;
- ?>
- </body>
- </html>
File Description
- while
- PHP Code
- 29 Oct-2019
- 1.09 Kb
You can Share it:
Latest PHP Pastes