Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="it">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <?php
- function stampa_array($array_da_stampare, $descrizioni) {
- for ($i=0; $i<count($array_da_stampare); $i++)
- echo $descrizioni[$i] . ":" . $array_da_stampare[$i] . "<br>";
- }
- ?>
- <?php
- $righe = file("promessi_sposi.txt", FILE_IGNORE_NEW_LINES);
- //statistiche quante vocali in percentuale
- $frequenze = [0,0,0,0,0]; //o for ($i=0; $i<5; $i++) $frequenze[] = 0;
- $vocali = ["a", "e", "i", "o", "u"];
- for ($i=0; $i<count($righe); $i++)
- {
- $riga = $righe[$i];
- for ($c=0; $c<strlen($riga); $c++)
- switch( strtolower($riga[$c]))
- {
- case "a":
- $frequenze[0]++;
- break;
- case "e":
- $frequenze[1]++;
- break;
- case "i":
- $frequenze[2]++;
- break;
- case "o":
- $frequenze[3]++;
- break;
- case "u":
- $frequenze[4]++;
- break;
- default:
- break;
- }
- }
- stampa_array($frequenze, $vocali);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement