if a lot of groups can be expected, it is probably better (faster) to set the array key as group name. Then you would test with isset($readGroups[$topGroup]) and set with $readGroups[$topGroup] = 1; two lines further down.