'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 ] ]; $showRatings = []; if (!empty($_GET[GET_PARAM_SEARCH_TEXT])) { $searchTerm = $_GET[GET_PARAM_SEARCH_TEXT]; foreach ($ratings as $rating) { if (strpos($rating['text'], $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; } function calcMeanStars (array $ratings) : float { $sum = 1; foreach ($ratings as $rating) { $sum += $rating['stars'] / count($ratings); } return $sum; } /** * */ ?>
| Text | Sterne | {$rating['text']} | {$rating['stars']} | "; } ?>