Skip to content

Instantly share code, notes, and snippets.

@surefirewebserv
Last active December 11, 2015 11:39
Show Gist options
  • Save surefirewebserv/4595700 to your computer and use it in GitHub Desktop.
Save surefirewebserv/4595700 to your computer and use it in GitHub Desktop.
This snippet strips the URI of the web address no matter what page your on. Then adds a meta description according to that page name. So in the case of 'connect' the web page would actually be www.sitename.com/whatever/connect.php and anything you put within that case, would only effect that page.
<?php
$thisPage = $_SERVER["REQUEST_URI"];
function get_page_name ( $page )
{
$array = explode( "/", $page );
for ( $i = 0; $i < count( $array ); $i++ )
{
$name = $array[ $i ];
}
$x = strpos( $name, ".php" );
$name = substr( $name, 0, $x );
$name = strtolower( $name );
return $name;
}
switch (get_page_name($thisPage)) {
case 'connect':
echo'<meta name="description" content="">';
break;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment