All pastes #409811 Raw Edit

Mine

public text v1 · immutable
#409811 ·published 2007-03-25 22:31 UTC
rendered paste body
<?php

$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.this-page.info/serpscrape/txtfile.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file = curl_exec($ch);
curl_close($ch);

// display file
//echo $file;



// get host name from URL
preg_match_all('@^(?:http://)?([^/]+)@i', $file, $matches);
$host = $matches[1];


$hosts = implode(" ", $host);
// get last two segments of host name
preg_match_all('/[^.]+\.[^.]+$/', $hosts, $matches);

echo "domain name is: {$matches[0]}\n";




//foreach ($matches as $val) {
 //  echo "matched: " . $val[0] . "\n";
   //echo "part 1: " . $val[1] . "\n";
   //echo "part 2: " . $val[3] . "\n";
   //echo "part 3: " . $val[4] . "\n\n";
//}


//THIS ALMOST WORKS
//$domain = preg_grep('/[^.]+\.[^.]+$/', $host);
//echo "domain name is: {$matches[0]}\n";
//foreach ($matches as $val) {
  // echo "matched: " . $val[0] . "\n";
   //echo "part 1: " . $val[1] . "\n";
   //echo "part 2: " . $val[3] . "\n";
   //echo "part 3: " . $val[4] . "\n\n";
//}



?>