Webbserverprogrammering 1

Show sourcecode

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

Webserver1/Ovningar/Repetition/

rep1.php
rep2.php
rep3b.php
rep3c.php
rep4.php
rep5.php

rep3c.php

32 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="sv">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Repetition Repetition Repetition</title>
</head>
<body>
  <form action="" method="get">
    <label for="amount">Hur många nummer ska slumpas ut?</label>
    <input type="number" name="amount">
    <input type="submit" value="Skicka">
  </form>
  <?php
  
include("rep3b.php");

  
$myArray = [];
  
$amount = isset($_GET["amount"]) ? $_GET["amount"] : NAN;

  if (!
is_nan($amount)) {
    for (
$i=0$i $amount$i++) { 
      
$myArray[] = mt_rand(110);
    }
    echo 
"<p>Värden: " implode(", "$myArray) . "</p>";
    echo 
"<p>Medelvärde: " medelvärde($myArray) . "</p>";
  }
  else {
    echo 
"<p>Inget antal angivet!</p>";
  }
  
?>
</body>
</html>