Files
intecsync/cgi-bin/uebung08/hangman_lib.php
2019-06-30 13:48:06 +02:00

48 lines
997 B
PHP

<?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 array(include("words-array.php"));
}
?>