int preg_match_all ( string $pattern , string $subject [, array &$matches [, int $flags = PREG_PATTERN_ORDER [, int $offset = 0 ]]] )
the third parameter is a matches array to store the matches.
In Match 0 is in what had matched exactly
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.<?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);
?>
Last edited by darkfrozen; 12-30-2018 at 12:15 PM.
int preg_match_all ( string $pattern , string $subject [, array &$matches [, int $flags = PREG_PATTERN_ORDER [, int $offset = 0 ]]] )
the third parameter is a matches array to store the matches.
In Match 0 is in what had matched exactly