How to avoid repeating the same code in this case
<p>In the code below there's a chunck of code that repeats itself. Can this be done in another way so that the code does not repeat. No matter what I try, I keep ending with the same thing. The code is below, but it's a lot more in the production version. This thing does country location.</p>

<pre><code>if ($GL)
{
 echo 'Managed to find your location';
}else{
 echo "Could not identify GL. Please select from the list below.";
}
</code></pre>

<p>This is the entire thing (stripped down).</p>

<pre><code>$GL = false; //GL is detected using ip to location, and returns boolean
$location = 'UK';//Read from a cookie.

if(isset($location))
{
    echo 'We found a cookie with your location&lt;br /&gt;';

    if(array_key_exists($location,$countries))
    {
        echo 'We found a country in the array. Carrying on&lt;br /&gt;';
    }else
    {
        echo 'Did not find a country in the array. Looking for GL';
        if ($GL)
        {
            echo 'Managed to find your location. Carrying on';
        }else{
            echo "Could not identify GL. Please select from the list below.";
            }
    }
}
else
{
    echo 'Did not find a location cookie&lt;br /&gt;';

    if ($GL)
    {
        echo 'Managed to find your location.Carrying on.';
    }else{
        echo "Could not identify GL. Please select from the list below.";
    }

}
</code></pre>
