21 lines
628 B
PHP
21 lines
628 B
PHP
<?php
|
|
|
|
// based on the page that called this include, we will set the hreflang
|
|
|
|
$languages = $config['locales'];
|
|
|
|
$list = [];
|
|
|
|
// for every key, rewrite it to be just the language code.
|
|
// for example, fil_PH becomes fil; taking note that we are removing _ and everything that follows
|
|
foreach ($languages as $key => $value) {
|
|
$key2 = str_replace('_', '-', $key);
|
|
$list[] = '<link rel="alternate" hreflang="' . $key2 . '" href="' . $config['app']['url'] . '/?lang=' . $key . '"/>' . PHP_EOL;
|
|
}
|
|
|
|
// dedupe $list
|
|
$list = array_unique($list);
|
|
|
|
foreach ($list as $link) {
|
|
echo $link;
|
|
} |