is115-php/modul1/index.php

33 lines
729 B
PHP

<?php
$dir = array_diff(scandir("./"), array('..','.','index.php','common.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>
<?php
foreach($dir as $item){
if(stristr($item, '.php')){
echo "<p><a href='$item'>".getModuleName($item)."</a></p>\n";
}
}
?>
</body>
</html>