Jazz12
Новичок
Нужно записать в файл все строки начинающиеся с www и до конца строки. Думаю хвост ссылки сам обрежу.
Вроде не тем путем пошел+)
И с регуляркой что то не то. Я только учусь.
<?
$handle = fopen("ishod.txt", "rt");
if(isset($handle));
{
$file = file_get_contents('ishod.txt');
preg_match_all('/www\.(.*)/', $file, $result);
function object2file($result, $filename)
{
$str_value = serialize($result);
$f = fopen($filename, 'w');
fwrite($f, $str_value);
fclose($f);
}
object2file($result, 'array.txt');
function object_from_file($filename)
{
$file = file_get_contents($filename);
$value = unserialize($file);
return $value;
}
echo '<pre>';
print_r(object_from_file('array.txt'));
echo '</pre>';
}
?>
Вроде не тем путем пошел+)
И с регуляркой что то не то. Я только учусь.
<?
$handle = fopen("ishod.txt", "rt");
if(isset($handle));
{
$file = file_get_contents('ishod.txt');
preg_match_all('/www\.(.*)/', $file, $result);
function object2file($result, $filename)
{
$str_value = serialize($result);
$f = fopen($filename, 'w');
fwrite($f, $str_value);
fclose($f);
}
object2file($result, 'array.txt');
function object_from_file($filename)
{
$file = file_get_contents($filename);
$value = unserialize($file);
return $value;
}
echo '<pre>';
print_r(object_from_file('array.txt'));
echo '</pre>';
}
?>