Skip to content

Instantly share code, notes, and snippets.

@jonsherrard
Forked from benhartley/active_game.php
Created October 8, 2012 15:08
Show Gist options
  • Save jonsherrard/3853019 to your computer and use it in GitHub Desktop.
Save jonsherrard/3853019 to your computer and use it in GitHub Desktop.
active_game.php
<?
$this->facebook_id = $facebook_id;
$active_game = array_filter($games, function($game) {
return $game->active;
});
/*
# Not sure this is needed, the game with the lowest game_id should be returned.
if (count($active_game) > 1):
$active_game = array_filter($active_game, function($game) {return $game->creator === $this->facebook_id;});
endif;
*/
# Instead, maybe just do:
$active_game = isset($active_game[0]) ? $active_game[0] || null
if ($active_game) $active_game[0]->garments = $this->get_garments($active_game[0]->game_id);
return $active_game;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment