ARTICLE AD BOX
The problem is that unsetting an array element reduces the value that count() returns, so your loop ends prematurely. You shouldn't use count() during the loop, get the value before the loop starts.
$playerCount = count($playersPool); for ($i = 0; $i < $playerCount; $i++) { if(in_array($playersPool[$r]['id'], $excludedPlayers)){ Schema::writeToLog('player removed: '.$playersPool[$r]['id']); unset($playersPool[$r]); } }Also, after doing all these unsets, you should reset the indexes with
$playersPool = array_values($playersPool);Otherwise, the second loop that creates $logString will have a similar problem (although it could simply be replaced with a call to implode()).
Another option would be to use array_filter() to remove elements.
$playersPool = array_filter($playersPool, function($player) { if(in_array($playersPool[$r]['id'], $excludedPlayers)){ Schema::writeToLog('player removed: '.$playersPool[$r]['id']); return false; } else { return true; } });This solves both problems.
