X-Git-Url: https://git.cweiske.de/stouyapi.git/blobdiff_plain/44491ef1b9b52e4ed4a5f245cbbeef123a436b18..ad9f3cf5a07338134a29fee4b6215c50cb8142c8:/bin/filters.php diff --git a/bin/filters.php b/bin/filters.php index 04a998f..628936a 100644 --- a/bin/filters.php +++ b/bin/filters.php @@ -65,6 +65,17 @@ function filterByPlayers($origGames, $numOfPlayers) return $filtered; } +function filterBySearchWord($origGames, $searchWord) +{ + $filtered = []; + foreach ($origGames as $game) { + if (stripos($game->title, $searchWord) !== false) { + $filtered[] = $game; + } + } + return $filtered; +} + function filterLastUpdated($origGames, $limit) { $games = array_values($origGames); @@ -90,4 +101,15 @@ function filterBestRated($origGames, $limit) return array_slice($games, 0, $limit); } + +function sortByTitle($games) +{ + usort( + $games, + function ($gameA, $gameB) { + return strcasecmp($gameA->title, $gameB->title); + } + ); + return $games; +} ?>