Aufgabe 3 komplett
This commit is contained in:
@@ -3,7 +3,7 @@ const GET_PARAM_MIN_STARS = 'search_min_stars';
|
||||
const GET_PARAM_SEARCH_TEXT = 'search_text';
|
||||
const GET_PARAM_SHOW_DESCRIPTION = 'show_description';
|
||||
const GET_PARAM_SPRACHE = 'sprache';
|
||||
const GET_PARAM_TOP_FLOPP = 'top_flop';
|
||||
const GET_PARAM_TOP_FLOPP = 'top_flopp';
|
||||
/**
|
||||
* List of all allergens.
|
||||
*/
|
||||
@@ -90,6 +90,39 @@ if (!empty($_GET[GET_PARAM_SEARCH_TEXT])) {
|
||||
} 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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user