To grab the "page name"
<?php
// gets you the path after http://www.yourdomain.com
$path = $_SERVER["REQUEST_URI"];
$current_url = explode("-", $path);
$current_url = $current_url[1];
echo "path ".$path . "<br />" ;
echo "exploded url " .$current_url;
?>
I was able to make this method work with preg_replace to grab arrays of each word (stripping out everything but numbers and letters in a string.
<?php
// gets /beach/coast-guard-beach/
$path = $_SERVER["REQUEST_URI"];
$preg = preg_split('/[^a-z0-9]/', $path);
foreach ($preg as $key) {
print $key. "<br /> ";
}
?>
prints:
beach coast guard beach