Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Translate characters or replace substrings
<?php strtr(string $string, string $from, string $to): string
<?php                 $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         $elements = '';

        $list = self::getList($core->getPlates(), $core_parts);

        foreach ($list as $key => $item) {

            $replaced_template = strtr($match['x'], [$tag_list => $tag_first . $key . $tag_last]);

            $new_template = self::replaceKeys($replaced_template, $key, $key_pattern);

            $elements .= $core->render($new_template);

        }
<?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]);

            }

        }

        return $template;