I have been trying to get it so that my php will check that the website stored in the database is actually there before offering a link.( in a multiple list)
eg. if the site http://www.boohoo.com exists there will be a link to it, if not then it will simply say link not there.
I have tried a variety of options found online (fopen, $url etc )
and just cant seem to get it to work.
here is the code I am trying to insert it into:

<?php 
 foreach ($myairports as $myairport)
{

echo'<tr>';
    echo'<td><h3>'.$myairport->name.'</h3></td>';
    echo'<td>'.$myairport->icao.'</td>';
    echo'<td><a href="'.$myairport->chartlink.'" target="_blank">View here</a></td>';





echo'</tr>';

}
?>

</table>

The problem that I am having is that it needs to check for each row of the table.

Here is a function I found in about 1 minute of searching.

function url_exists($url) {
    // Version 4.x supported
    $handle   = curl_init($url);
    if (false === $handle)
    {
        return false;
    }
    curl_setopt($handle, CURLOPT_HEADER, false);
    curl_setopt($handle, CURLOPT_FAILONERROR, true);  // this works
    curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox   
    curl_setopt($handle, CURLOPT_NOBODY, true);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, false);
    $connectable = curl_exec($handle);
    curl_close($handle);  
    return $connectable;
}

Seems pretty simple and straight forward.

To integrate:

<?php
foreach ($myairports as $myairport)
{
echo'<tr>';
echo'<td><h3>'.$myairport->name.'</h3></td>';
echo'<td>'.$myairport->icao.'</td>';
echo'<td>';
if ( url_exists( $myairport->chartlink ) ) {
echo '<a href="'.$myairport->chartlink.'" target="_blank">View here</a></td>';
echo '</td>';
echo'</tr>';
}
?>

Honestly, I wouldn't do this because it will be slow.