Цитата (twin @ 2.03.2016 - 12:12) |
Не дурите человеку голову массивами. В данном случае switch() предпочтительнее. Сама компановка не совсем красивая, но от массива потом головняков больше будет. А к роутингу он сам потом придет. |
echo "<a href='$value' ".((preg_match("/$value/",$_SERVER['PHP_SELF']))?" style='color:blue'":"").">$key</a>";
$menuArray = [
'indx' => [
'file' => 'indx.php',
'title' => 'Главная',
'description' => 'Интернет займы для всех.',
'keywords' => 'кредиты, онлайн',
'css' => 'style.css',
'style' => '',
],
'about' => [
'file' => 'about.tpl',
'title' => 'About Us',
'description' => 'About Us',
'keywords' => 'about us',
'css' => 'style.css',
'style' => 'style="aboutus"'
],
'faq' => [...],
'call' => [...],
];
$page = isset($_GET['page']) ? stripslashes($_GET['page']) : 'indx';
// Если страница не найдена
if(!is_array($menuArray[$page])){
$page = 'indx';
}
<title><?php echo $menuArray[$page]['title']; ?></title>
<link rel="icon" href="http://адрес-сайта.ru/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://адрес-сайта.ru/favicon.ico" type="image/x-png" />
<meta itemprop="description" name="description" content="<?php echo $menuArray[$page]['description']; ?>" />
<meta itemprop="keywords" name="keywords" content="<?php echo $menuArray[$page]['keywords']; ?>" />
<meta name="robots" content="noindex,nofollow,noodp,noydir" />
<link rel="stylesheet" type="text/css" href="<?php echo $menuArray[$page]['css']; ?>" />
......
<ul>
<?php
foreach ($nemuArray AS $page=>$value){
$url = ($page == 'indx') ? './' : 'index.php?page='.$value['page'];
echo '<li itemprop="name"><a '.$value['style'].' href="'.$url.'">'.$value['title'].'</a></li>';
}
?>
</ul>
$url = ($page == 'indx') './' ? 'index.php?page='.$value['page'];