<?php $GAMES_TO_INCLUDE = [ "minecraft", "sauerbraten" ]; function getGameStatus($templateHeader = FALSE,$templateFooter = FALSE){ global $GAMES_TO_INCLUDE; $gameInfo = []; foreach ($GAMES_TO_INCLUDE as $game){ include "$game.php"; $a = "$game\\getInfo"; $thisGame = $a(); $gameInfo[$game] = $thisGame; if ($templateHeader !== FALSE){ echo $templateHeader; echo "<div data-target=\"$game\">"; echo preg_replace_callback("/{{([^|]*)\|([^}]*)}}/",function ($matches) use ($thisGame){ $elem = $matches[1]; $key = $matches[2]; $val = $thisGame[$key]; return "<$elem data-target='$key'>$val</$elem>"; },file_get_contents("$game.html")); echo "</div>"; echo $templateFooter; } } return $gameInfo; } ?>