Show sourcecode
The following files exists in this folder. Click to view.
index.html
ovn_form1.php
ovn_form2.php
ovn_form3.php
ovn_form4.php
ovn_form5.php
ovn_form6.php
ovn_form7.php
ovn_form8.php
svar.php
svar3.php
svar4.php
svar5.php
svar6.php
svar7.php
svarget.php
ovn_form8.php
29 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">
<title>Document</title>
</head>
<body>
<form method="post" action="">
<input type="number" name="tal1"> <br>
<input type="number" name="tal2"> <br>
<input type="number" name="tal3"> <br>
<input type="submit" value="Beräkna">
</form>
<?php
if($_POST["tal1"] != ""){
echo "Talen är ".$_POST["tal1"] . ", ".$_POST["tal2"] . " och ".$_POST["tal3"] . ". ";
$array = [$_POST["tal1"], $_POST["tal2"], $_POST["tal3"]];
function medelv(&$array){
$len = count($array);
$summa = array_sum($array);
echo " <br> Medelvärdet är ". $summa/$len, "<br>";
}
medelv($array);
}
?>
</body>
</html>