zero-perfoliate
zero-perfoliate

Author Topic: $pages = array  (Read 389 times)

Offline tbint

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
$pages = array
« on: July 09, 2010, 07:14:00 PM »
would any one know a way I could write this array so I did not have to include a file for 'name'. 'name' is used for defining the included 'page'. So I can high light the current link. for every page thats included I have to include a separate file with define('this_page', 'home'); and the next define('this_page', 'about');.

a away I could use something like echo('name'); or print and define('this_page', 'home'); will echo. Then I would not have to write a file for every page.

Code: [Select]
$pages = array (
  1 => array('name' => 'set/home.txt' , 'title' => 'No Title' , 'page' => 'pages/home.txt'),
  2 => array('name' => 'set/about.txt' , 'title' => 'About Us' , 'page' => 'pages/about.txt'),
  3 => array('name' => 'set/contact.txt' , 'title' => 'Contact Us' , 'page' => 'pages/contact.txt')
   );

  if (isset ($_GET['id'])) {
$pageID = $_GET['id'];
if (! isset($pages[$pageID])) $pageID = 404;
  } else {
$pageID = 1;
  }

  include($pages[$pageID]['name']); //defines the page

 

zero-perfoliate