Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- </head>
- <body>
- <?php
- $fp= fopen('zadanie.txt', 'w');
- for($i=0;$i<=30;$i++){
- $x=rand(1,15).';';
- fwrite($fp,$x);
- }
- $fs = fopen('zadanie.txt','r');
- /* while(!feof($fs)){
- echo fgetc($fs);
- }
- */
- $y=stream_get_contents($fs,500);
- $nazwa= preg_split('/[;]/', $y);
- for($i=0;$i<=31;$i++){
- echo $nazwa[$i].' ' ;
- }
- echo "<br>";
- echo "suma to: ";
- echo $suma=array_sum($nazwa);
- echo "<br>";
- echo "średnia to:". $suma/30;
- fclose($fs);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement