Good idea and create groups of arrays with example names,
$arrays =
array(
array( 'teamID' => '1151', 'username' => 'iLilithZ'),
array( 'teamID' => '1111', 'username' => 'iLilithZ'),
array( 'teamID' => '1151', 'username' => 'iLilithZ'),
array( 'teamID' => '1111', 'username' => 'iLilithZ'),
array( 'teamID' => '0', ' username' => 'iLilithZ'),
);
By doing a foreach of these array, so the array with equal teamID will show an echo in the foreach of group 1, the others id equals group 2, etc.