Forum Moderators: coopster
<?php
include("conf.php");
?>
<html>
<head>
<title><?php echo $title;?></title>
<?php
@session_start();
$url= "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if ($url="http://www.url.com/index.php") echo $title="Index Title";
if ($url="http://www.url.com/signup") echo $title="Signup Title";
$pages = array(
'home' => array(
'header' => 'My Home Page Title',
'title' => 'My Home Meta Title',
'description' => 'My Home Meta Description'
),
'about' => array(
'header' => 'My About Page Title',
'title' => 'My About Meta Title',
'description' => 'My About Meta Description'
)
);
<title><?php echo $pages['home']['title']; ?></title>
<title> <?php $pages['home']['title']['about']['title']['signup']['title']; ?>
Have a look at the arrays [php.net] page from the manual, particularly example #7 and the ones that follow to get an idea of how to construct and dereference multidimensional arrays (arrays inside other arrays) to achieve the result you need. The example you posted infers an array inside an array inside an array inside an array ..... etc.
@session_start();
$metas = array(
'index.php' => array(
'header' => 'Home Page Title',
'title' => 'Home Meta Title',
'description' => 'Home Meta Description'
),
'signup' => array(
'header' => 'Signup Title',
'title' => 'Signup Meta Title',
'description' => 'Signup Meta Description'
),
'about' => array(
'header' => 'About Title',
'title' => 'About Meta Title',
'description' => 'About Meta Description'
)
);
$title = $metas['index.php'];
$title = $metas['signup'];
$title = $metas['about'];
<TITLE><?php echo $title['title']; ?></TITLE>
$url = $_GET['REMOTE_ADDR'];
if ($url= "example.com/signup) echo $title"Signup Title"
href="/about" with a leading slash. RewriteRule ^([^/.]+)$ /index.php?page=$1 [L] $_SERVER['page'] to find what page was requested. $page to pull the right record from the array.