Add uebung8

This commit is contained in:
2019-06-30 13:38:50 +02:00
parent 73abfccad7
commit d18c038d38
20 changed files with 2711 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?php
// startet die Session und initialisiert das tasks-Array
function startHangmanSession()
{
// Setze einen eindeutigen Session-Name: zdvlogin mit suffix todo
// get_current_user() liefert den Benutzernamen
session_name(get_current_user() . "hangman");
session_start();
if (!isset($_SESSION['state'])) {
resetTasks();
}
}
// Löscht alle Session Daten
function resetTasks()
{
$_SESSION['state'] = [];
}
//Bringt ein Wort in das richtige Format
function transformWord($word) {
$word = strtoupper($word);
$word = str_replace("Ä", "AE", $word);
$word = str_replace("Ö", "OE", $word);
$word = str_replace("Ü", "UE", $word);
$word = str_replace("ß", "SS", $word);
return $word;
}
//Maskiert ein Wort mit _
function maskWord($word) {
$arr = array();
for ($i = 0; i < strlen($word); $i++) {
$arr[] = "_";
}
return $arr;
}
function getAllWords() {
return include("words-array.php");
}
?>