Supported Versions: PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8
Removes duplicate values from an array
<?php array_unique(array $array, int $flags = SORT_STRING): array
<?php             $data = $content;

            if (isset($matches['x'])) {

                $unique_matches = array_unique($matches['x']);

                foreach ($unique_matches as $key => $match) {

                    $replace_with = $class->find(['x' => $match]);

                    $data = strtr($data, [$matches[0][$key] => $replace_with]);
<?php     private static function replaceKeys(string $template, string $key, string $pattern): string {

        if (preg_match_all($pattern, $template, $key_matches) > 0) {

            foreach (array_unique($key_matches[0]) as $key_match) {

                $template = strtr($template, [$key_match => $key]);

            }

        }