text.txt - урлы
text_redirects.txt - результат.
Код:
<?
$f = file("text.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
foreach ($f as $k => $v) {
curl_setopt($ch, CURLOPT_URL, trim($v));
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$fo = fopen("text_redirects.txt", "a");
fwrite($fo, $info['url'] ."\n");
fclose($fo);
}
curl_close($ch);
?>