Function – PHP Detects a straight 5 card within a set of 7 cards

I have this function that can detect a Straight in Poker if the hand is exactly 5 cards but you are not so sure how to find one if it is among the 7 cards.

        public function directly ($ hand) {
sort ($ hand);
if ($ hand == range ($ hand[0], $ hand[count($hand)-1])) {
$ this-> hand_name = & # 39; straight & # 39 ;;
}
}

Suppose that the matrix is ​​already just a string of numbers. So these would be the desired results.

2 3 5 7 12 7 4 - without ladder

2 3 5 6 12 7 4 - straight

7 8 9 10 11 11 11 - straight

2 4 5 6 14 10 9 - without ladder

Do not worry that the Ace is a problem of 1 or 14 for now, I can solve it, but the function should allow duplicates since that is how the cards are.

Also keep in mind that I only need to determine if there are five cards in a row or not … I do not need to involve them or compare them with another one, etc.