$maxRange) { $group[] = [ $tag, $beginLeft, min($endLeft, $beginLeft + $context), $beginRight, min($endRight, $beginRight + $context) ]; $groups[] = $group; $group = []; $beginLeft = max($beginLeft, $endLeft - $context); $beginRight = max($beginRight, $endRight - $context); } $group[] = [$tag, $beginLeft, $endLeft, $beginRight, $endRight]; } if (!empty($group) && !(count($group) === 1 && $group[0][0] === 'equal')) { $groups[] = $group; } return $groups; } }