Created
January 30, 2019 11:45
-
-
Save kadimi/b4645f8ee57f77bc884de0acc79f0dc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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