Create PHP Title & Meta Description Tags with PHP Array
Posted on July 20, 2012 in Array, Function, PHP by Matt Jennings
Below is a function on how to create tags with an array and foreach method.
<?php
function title_meta_descrip()
{
$_url = $_SERVER[REQUEST_URI];
$phpfilename = array
(
'/index.php' => '<meta name="description" content="Home Page" />',
'/contact.php' => '<meta name="description" content="Contact Page" />'
);
}
foreach ($phpfilename as $_url => $value)
{
if($_url == $_SERVER[REQUEST_URI])
{
echo $value;
}
}
?>