<?php
$n=1;
$file="/var/www/trainer/" .htmlspecialchars($_GET["name"]) .".json";
header('Content-Type: text/plain');
header('Content-disposition: attachment; filename="' . basename($file,".json") . '.txt"'); 
foreach(json_decode(file_get_contents($file),true) as  $question) {
        echo $n++ .". ". $question["question"]."\n\n";
        foreach($question['items'] as $m => $item) echo chr($m + ord("A")).") ".$item."\n";
        echo "\n";
        echo "Lösung: ".$question['solution'] ." ".$question['solution_comment']."\n";
        echo "\n";
}
?>
