Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbserverprogrammering/exercises/repetition/

ovning_1.php
ovning_2.php
ovning_3a.php
ovning_3b.php
ovning_3c.php
ovning_4.php
ovning_5.php
ovning_6.php
ovning_7.php

ovning_3a.php

32 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
  <title>Övning 3a</title>
</head>
<body>
  <?php
    $values 
= [447992232450];

    function 
getAverage($array) {
      
$total 0;

      foreach (
$array as $num) {
        
$total += $num;
      }

      
$average $total/count($array);

      return 
$average;
    }

    
$average getAverage($values);

    echo 
"Vi har en lista med värdena: ".implode(", "$values);
    echo 
"<br><br>";
    echo 
"Medelvärdet av dessa värden är: <strong>$average<strong>";
  
?>
</body>
</html>