Is there a way to make file_get_contents
perform a quick function within a loop?
Follow the code
<?php foreach ($links->result() as $value) : ?>
<?php
$url = $value->lnkUrl;
$domain = parse_url($url, PHP_URL_HOST);
$web_link = "http://".$domain;
$str = file_get_contents($web_link);
if(strlen($str)>0){
preg_match("/\<title\>(.*)\<\/title\>/",$str,$title);
if ( isset( $title[1] ) ) {
echo "<span class='directi_web' title='".$title[1]."'>". $title[1] ."</span>";
}else{
echo "<span class='directi_web'>...</span>";
}
}
?>
<?php endforeach; ?>