<?php

function getSequentiallyRepeated(array $numbers): array {
    $repeated = [];

    for ($i = 0; $i < count($numbers) - 1; $i++) {
        if ($numbers[$i] === $numbers[$i + 1]) {
            $repeated[] = $numbers[$i];
        }
    }

    return array_values(array_unique($repeated));
}

$test1 = [1, 2, 2, 6, 3, 3, 3, 3, 5, 5, 2, 7, 3];
print_r(getSequentiallyRepeated($test1));