simply adding code to php function
<p>I want to create a php function with the following code but when I add this to a function it stops working:
<br><br>Code works:</p>

<pre><code>    $arr = array(
        "index.php" =&gt; $home, 
        "about.php" =&gt; $about, 
        "details.php" =&gt; $details
    );
    $url = basename($_SERVER['PHP_SELF']);

    foreach($arr as $key =&gt; $value){

        if($url == $key) {
            echo $value;
        }
    }
</code></pre>

<p>Code Doesnt work:</p>

<pre><code>function metaData() {
    $arr = array(
        "index.php" =&gt; $home, 
        "about.php" =&gt; $about, 
        "details.php" =&gt; $details
    );
    $url = basename($_SERVER['PHP_SELF']);

    foreach($arr as $key =&gt; $value){

        if($url == $key) {
            echo $value;
        }
    }
}

metaData(); // NULL
</code></pre>