Skip to content

Instantly share code, notes, and snippets.

@rogeruiz
Created June 4, 2011 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogeruiz/1007469 to your computer and use it in GitHub Desktop.
Save rogeruiz/1007469 to your computer and use it in GitHub Desktop.
2D Array for Simple Site Navigation
<?php
$location = array(
"home" => array(
"loc" => TRUE,
"title" => "Nine Points Collection | Portfolio of Roger Steve Ruiz",
"href" => "index.php",
"desc" => "Nine Points Co."
),
"portfolio" => array(
"loc" => TRUE,
"title" => "Nine Points Collection | Latest Work",
"href" => "portfolio.php",
"desc" => "Latest work"
),
"about" => array(
"loc" => TRUE,
"title" => "Nine Points Collection | About Roger Steve Ruiz",
"href" => "about.php",
"desc" => "More information"
),
"contact" => array(
"loc" => TRUE,
"title" => "Nine Points Collection | Contact Roger Steve Ruiz",
"href" => "contact.php",
"desc" => "Let's get personal"
)
);
switch ($title) {
case "portfolio":
$location["portfolio"]["loc"] = FALSE;
$title = $location["portfolio"]["title"];
break;
case "about":
$location["about"]["loc"] = FALSE;
$title = $location["about"]["title"];
break;
case "contact":
$location["contact"]["loc"] = FALSE;
$title = $location["contact"]["title"];
break;
default:
$location["home"]["loc"] = FALSE;
$title = $location["home"]["title"];
}
?>
<ul>
<?php
foreach ($location as $key => $val):
if (!$val["loc"]):
?>
<li>
<h4><?php echo ucwords($key); ?></h4>
<span><?php echo $val["desc"]; ?></span>
</li>
<?php else: ?>
<li>
<a href="<?php echo $val["href"]; ?>">
<h4><?php echo ucwords($key); ?></h4>
<span><?php echo $val["desc"]; ?></span>
</a>
</li>
<?php
endif;
endforeach;
?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment