private static function getRandomWinner(&$data, &$alreadyWinners) {
    // Randomize array.
    shuffle($data);

    $memberCampaignItem = array_shift($data);

    if (!in_array($memberCampaignItem['member_campaign'], $alreadyWinners)) {
      $alreadyWinners[] = $memberCampaignItem['member_campaign'];
      return $memberCampaignItem;
    }
    else {
      if (!empty($data)) {
        return self::getRandomWinner($data, $alreadyWinners);
      }
    }
  }
private static function getRandomWinner(&$data, &$alreadyWinners) {
    // Randomize array.
    shuffle($data);

    $memberCampaignItem = array_shift($data);

    if (!in_array($memberCampaignItem['member_campaign'], $alreadyWinners)) {
      $alreadyWinners[] = $memberCampaignItem['member_campaign'];
      return $memberCampaignItem;
    }
    else {
      if (!empty($data)) {
        return self::getRandomWinner($data, $alreadyWinners);
      }
    }
  }
private static function getRandomWinner ( & $ data , & $ alreadyWinners ) { // Randomize array. shuffle ( $ data ) ; $ memberCampaignItem = array_shift ( $ data ) ; if ( ! in_array ( $ memberCampaignItem [ 'member_campaign' ] , $ alreadyWinners ) ) { $ alreadyWinners [ ] = $ memberCampaignItem [ 'member_campaign' ] ; return $ memberCampaignItem ; } else { if ( ! empty ( $ data ) ) { return self :: getRandomWinner ( $ data , $ alreadyWinners ) ; } } }
Recursive function to get random winner excluding already won members.

@param array $data
@param array $alreadyWinners

@return mixed
Recursive function to get random winner excluding already won members .