Reputation: 343
A rather simple scenario; I've got an array of user inputted url's (could be any number from 1 to 1000+), and I want to perform file_get_contents();
on all of them, and then if possible have all that binded/bound into a single variable, so that preg_match_all();
can be performed on that variable to pick up specific strings.
I've heard that using cURL might be another option, however I've got very little knowledge on the function of cURL.
Upvotes: 0
Views: 2264
Reputation: 197659
Actually this sounds like a job for iterating over the URLs:
$urls = array('http://www.example.com/');
$allTexts = '';
foreach($urls as $url)
{
$text = file_get_contents($url);
if (false === $text)
continue;
// proceed with your text, e.g. concatinating it:
$allTexts .= $text;
}
However if you have thousand URLs, take your time. curl offers to request multiple URLs at once (multi request feature) however, with thousands of URLs that does not scale as well.
Upvotes: 3