Show sourcecode
The following files exists in this folder. Click to view.
ovning1.php
ovning2.php
ovning3.php
ovning4.php
ovning5.php
test.php
ovning5.php
47 lines UTF-8 Windows (CRLF)
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>gr_ovning5</title>
<style>
body{
flex-direction: column;
flex-wrap: wrap;
display: flex;
}
div{
padding: 40px;
max-width: fit-content;
max-height: fit-content;
background-color: red;
margin: 10px;
}
</style>
</head>
<body>
<?php
$x = 1;
$values = array();
for ($i = 1; $i <= 10; $i ++){
echo ("<div>". $x. "</div>");
$values[] = $x;
$x = $x * 2;
}
function calculateSum($values){
$sum = 0;
for ($i = 1; $i <= count($values); $i++){
$sum = $values[$i - 1];
}
return $sum / count($values);
}
$sum = calculateSum($values);
echo ("Medelvärde: ". $sum);
?>
</body>
</html>