- Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- array(2) { [0]=> string(8) "Player 5" [1]=> string(8) "Player 1" }
<?php
$inputArduino = 17;
var_dump(unparserPlayerRounds($inputArduino));
function unparserPlayerRounds(int $bitNumber): array
{
$playerArray = [];
$players = [
32 => 'Player 6',
16 => 'Player 5',
8 => 'Player 4',
4 => 'Player 3',
2 => 'Player 2',
1 => 'Player 1',
];
while($bitNumber !== 0) {
foreach ($players as $bitValue => $player) {
if ($bitNumber >= $bitValue) {
$playerArray[] = $player;
$bitNumber -= $bitValue;
}
}
}
return $playerArray;
}