Skip to content

Instantly share code, notes, and snippets.

@kadimi
Created January 30, 2019 11:45
Show Gist options
  • Save kadimi/b4645f8ee57f77bc884de0acc79f0dc2 to your computer and use it in GitHub Desktop.
Save kadimi/b4645f8ee57f77bc884de0acc79f0dc2 to your computer and use it in GitHub Desktop.
<?php
/**
* Get player performance for event.
*
* @param int $player_id Player ID.
* @param int $team_id Team ID.
* @param int $event_id Event ID.
* @return array|false Array of player performance or false
* if one of the parameters is not valid.
*/
function sp_get_player_performance( $player_id, $team_id, $event_id ) {
$event_players = get_post_meta( 1947, 'sp_players', true );
if ( ! is_array( $event_players ) ) {
return [];
}
if ( ! array_key_exists( $team_id, $event_players ) ) {
return [];
}
if ( ! array_key_exists( $player_id, $event_players[ $team_id ] ) ) {
return [];
}
return $event_players[ $team_id ][ $player_id ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment