'Gluten', 12 => 'Krebstiere', 13 => 'Eier', 14 => 'Fisch', 17 => 'Milch' ]; $meal = [ 'name' => 'Süßkartoffeltaschen mit Frischkäse und Kräutern gefüllt', 'description' => 'Die Süßkartoffeln werden vorsichtig aufgeschnitten und der Frischkäse eingefüllt.', 'price_intern' => 2.90, 'price_extern' => 3.90, 'allergens' => [11, 13], 'amount' => 42 // Number of available meals ]; $ratings = [ [ 'text' => 'Die Kartoffel ist einfach klasse. Nur die Fischstäbchen schmecken nach Käse. ', 'author' => 'Ute U.', 'stars' => 2 ], [ 'text' => 'Sehr gut. Immer wieder gerne', 'author' => 'Gustav G.', 'stars' => 4 ], [ 'text' => 'Der Klassiker für den Wochenstart. Frisch wie immer', 'author' => 'Renate R.', 'stars' => 4 ], [ 'text' => 'Kartoffel ist gut. Das Grüne ist mir suspekt.', 'author' => 'Marta M.', 'stars' => 3 ] ]; $dic = [ [ "Gericht" => "Gericht", "Allergien" => "Allergien", "Bewertungen" => "Bewertungen (Insgesamt: ", "Text" => "Text", "Sterne" => "Sterne", "Author" => "Author", "Preis" => "Preis", "Gaeste" => "Gäste" ], [ "Gericht" => "Meal", "Allergien" => "Allergies", "Bewertungen" => "Review (overall: ", "Text" => "Text", "Sterne" => "Stars", "Author" => "Author", "Preis" => "Price", "Gaeste" => "Guests" ] ]; $translation = $dic[0]; $language = "de"; if (!empty($_GET[GET_PARAM_SPRACHE])){ $language = $_GET[GET_PARAM_SPRACHE]; } if($language == "en"){$translation = $dic[1];} if (empty($_GET[GET_PARAM_SHOW_DESCRIPTION])){ $meal['description'] = ""; } $searchTerm = ""; $showRatings = []; if (!empty($_GET[GET_PARAM_SEARCH_TEXT])) { $searchTerm = $_GET[GET_PARAM_SEARCH_TEXT]; foreach ($ratings as $rating) { if (strpos(strtolower($rating['text']), strtolower($searchTerm) )!== false) { $showRatings[] = $rating; } } } else if (!empty($_GET[GET_PARAM_MIN_STARS])) { $minStars = $_GET[GET_PARAM_MIN_STARS]; foreach ($ratings as $rating) { if ($rating['stars'] >= $minStars) { $showRatings[] = $rating; } } } else { $showRatings = $ratings; } if (!empty($_GET[GET_PARAM_TOP_FLOPP])){ $flopp = $_GET[GET_PARAM_TOP_FLOPP]; if($flopp == "flopp"){ unset($showRatings); $showRatings=[]; $stars=[]; foreach ($ratings as $rating) { $stars[] = $rating["stars"]; } $min = min($stars); foreach ($ratings as $rating) { if ($rating['stars'] == $min) { $showRatings[] = $rating; } } } elseif ($flopp == "top"){ unset($showRatings); $showRatings=[]; $stars=[]; foreach ($ratings as $rating) { $stars[] = $rating["stars"]; } $min = max($stars); foreach ($ratings as $rating) { if ($rating['stars'] == $min) { $showRatings[] = $rating; } } } } /** *:float gibt den return value der Funktion an */ function calcMeanStars (array $ratings) : float { $sum = 0; foreach ($ratings as $rating) { $sum += $rating['stars'] / count($ratings); } return $sum; } /** * */ ?> <?php echo $translation["Gericht"].": ". $meal['name']; ?>


)

>
"; } ?>
{$rating['text']} {$rating['stars']} {$rating['author']}


Deutsch oder English