is115-php/modul8/index.php

41 lines
870 B
PHP

<?php
$modul = substr($_SERVER['REQUEST_URI'],-2,1);
function getModuleName($input): string {
$oppg = substr($input, -5, 1);
if(is_numeric($oppg)){
return "Oppgave $oppg";
}
return explode('.', $input)[0];
}
?><!DOCTYPE html>
<html lang="no">
<head>
<title>IS-115 - Webprogrammering i PHP</title>
<link rel="stylesheet" href="../index.css">
</head>
<body>
<h1>IS-115 - Webprogrammering i PHP</h1>
<h3>
Modul <?=$modul;?>
</h3>
<h5>
<strong><a href="../">Tilbake til alle moduler</a></strong>
</h5>
<?php
$dir = array(
"index8_1.php",
"index8_2.php",
"index8_3.php",
"index8_4.php",
"index8_5.php"
);
foreach($dir as $item){
echo "<p><a href='$item'>".getModuleName($item)."</a></p>\n";
}
?>
</body>
</html>