git.cweiske.de
/
stouyapi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add search support
[stouyapi.git]
/
bin
/
filters.php
diff --git
a/bin/filters.php
b/bin/filters.php
index 04a998f2b985259ba00874281faafc1653109d81..628936a899e2057499f56a1ad7d5e3a14e0174e7 100644
(file)
--- a/
bin/filters.php
+++ b/
bin/filters.php
@@
-65,6
+65,17
@@
function filterByPlayers($origGames, $numOfPlayers)
return $filtered;
}
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);
function filterLastUpdated($origGames, $limit)
{
$games = array_values($origGames);
@@
-90,4
+101,15
@@
function filterBestRated($origGames, $limit)
return array_slice($games, 0, $limit);
}
return array_slice($games, 0, $limit);
}
+
+function sortByTitle($games)
+{
+ usort(
+ $games,
+ function ($gameA, $gameB) {
+ return strcasecmp($gameA->title, $gameB->title);
+ }
+ );
+ return $games;
+}
?>
?>