how to save the result obtained with preg_match_all in a text file
Hello. How are you? Is it possible to save the result of preg_match_all in a text?
this is my code But it's not working.
I hope you can help me, thank you very much.
this is my code But it's not working.
<?php
$html = file_get_contents("https://example.com/imag-ad6c66810qs4.html");
preg_match_all(
'/(https:..\w\w\w\w\w\w,.urlset.*png)/',
$html,
$posts,
PREG_SET_ORDER
);
foreach ($posts as $post) {
$link = $post[0];
}
$file = fopen("file.txt", "w");
fwrite($file, "$link" . PHP_EOL);
fclose($file);
?>
$html = file_get_contents("https://example.com/imag-ad6c66810qs4.html");
preg_match_all(
'/(https:..\w\w\w\w\w\w,.urlset.*png)/',
$html,
$posts,
PREG_SET_ORDER
);
foreach ($posts as $post) {
$link = $post[0];
}
$file = fopen("file.txt", "w");
fwrite($file, "$link" . PHP_EOL);
fclose($file);
?>