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_1.php

34 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 1</title>
</head>
<body> 
  <h2>Vi har en låda med värdena:</h2>
  <?php
    $x 
1;
    
$boxes = [[], [], [], [], [], [], [], [], [], []];
    
$average 0;

    foreach (
$boxes as &$box) {
      
$box[0] = [$x];
      
$x *= 2;
    }
    unset(
$box);

    foreach (
$boxes as $box) {
      echo 
implode($box[0]).", ";
      
$average += (int)implode($box[0]);
    }
    unset(
$box);

    echo 
"<br><br>Medelvärdet är <strong>".$average/count($boxes)."</strong>"
  
?>

  <?php
?>
</body>
</html>