} //Don't proceed when no link was found if (empty($pdfLink)) { return; } // Parse pdf file and build necessary objects. $parser = new \Smalot\PdfParser\Parser(); $pdf = $parser->parseFile($pdfLink); $text = $pdf->getText(); //Store it in cache apc_store('hungertext' . $weekNumber, $text, 2 * 24 * 3600); //return it return $text; } //Process the PDF $raw = preg_split('/\\n\\s*\\n/', pdfToString()); //split the whole pdf string on the days $days = array_slice($raw, 4, count($raw) - 7); // Remove unneded stuff $currentDayOfWeek = idate('w', time()); // Only display today and future days $i = 1; $output = []; foreach ($days as $day) { //Only show future dates and today if ($i >= $currentDayOfWeek) { $dayArray = preg_split('/\\n\\d[.]/', $day); $title = array_shift($dayArray); $output[$title] = []; foreach ($dayArray as $meal) { $meal = preg_replace('/ oder B.n.W. /', '', $meal);
return $text; } ?> <html> <head> <title>Hunger!11!! - Speiseplan MI, TUM</title> <meta charset="UTF-8"> <link href="http://fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css"> <link href="/hunger/style.css" rel="stylesheet" type="text/css"> </head> <body> <h1>Hunger | <a href="http://tum.sexy" class="logo">TUM.<strong>sexy</strong></a></h1> <div class="container"> <p>This is the 'Speiseplan' of the current week in the FMI Bistro of the Informatik Fakultät at TUM.</p> <?php $raw = preg_split("/\n\\s*\n/", pdfToString()); //split the whole pdf string on the days $days = array_slice($raw, 4, count($raw) - 7); // Remove unneded stuff $currentDayOfWeek = idate('w', time()); // Only display today and future days $i = 1; foreach ($days as $day) { if ($i >= $currentDayOfWeek) { $dayArray = preg_split("/\n\\d[.]/", $day); $title = array_shift($dayArray); echo "<h3>" . $title . "</h3>"; echo "<ul>"; foreach ($dayArray as $meal) { echo "<li>" . preg_replace("/\\d([,]\\d*)* oder B.n.W./", "", $meal) . "€</li>"; }