Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10.  
  11.  
  12.  
  13. <?php
  14.  
  15. $fp= fopen('zadanie.txt', 'w');
  16.  
  17. for($i=0;$i<=30;$i++){
  18.  
  19. $x=rand(1,15).';';
  20. fwrite($fp,$x);
  21. }
  22. $fs = fopen('zadanie.txt','r');
  23. /* while(!feof($fs)){
  24. echo fgetc($fs);
  25. }
  26. */
  27. $y=stream_get_contents($fs,500);
  28. $nazwa= preg_split('/[;]/', $y);
  29.  
  30. for($i=0;$i<=31;$i++){
  31.  
  32. echo $nazwa[$i].' ' ;
  33. }
  34. echo "<br>";
  35. echo "suma to: ";
  36. echo $suma=array_sum($nazwa);
  37. echo "<br>";
  38. echo "średnia to:". $suma/30;
  39. fclose($fs);
  40.  
  41.  
  42. ?>
  43.  
  44.  
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement