Right, I'm trying to grab links from a web page. links are stored in the $ links array.
Is there a way to capture the name (from the function below) from each link in the array. will it be a multidimensional array? How can i do this?
$links = Array(); $URL = 'http://www.theqlick.com'; // change it for urls to grab // grabs the urls from URL $file = file_get_html($URL); foreach ($file->find('a') as $theelement) { $links[] = url_to_absolute($URL, $theelement->href); } print_r($links); function getTitle($links) { //change it for the original titles. $str = file_get_contents("http://www.theqlick.com"); if ( strlen( $str )>0 ) { preg_match( "/\<title\>(.*)\<\/title\>/", $str, $title ); return $title[1]; } } $metatitle = getTitle(); echo $metatitle;
source share