<?php
ini_set('display_errors', 'Off');
for ($i=0; $i<=100000000000; $i+=1) {
$addres="http://export.yandex.ru/last/last20x.xml";
//echo $addres;
$content= @file_get_contents($addres);
if (strpos($content,"last20x")){
preg_match_all('/\">(.*?)<\/item>/i',$content,$suggkey);
$file = 'keywords.txt'; // Файл
$data_file = file($file); // Считываем данные из файла
for ($i=0; $i+1<=count($suggkey[1]); $i+=1) {
$string = trim($suggkey[1][$i].PHP_EOL ); // Строка для записи
// Тут убираем пробелы по краям записей
$data_file = array_map( "trim", $data_file );
// Смотрим, есть ли такая запись
if( !in_array($string, $data_file) )
{
$user = fopen( $file, 'a' );
fwrite( $user, $string."\n" );
}
}
fclose( $user );
//sleep(1);
}
}
?>