I have many HTTPS-URLS where I have to find a Special Phrase, so I´m trying to use cURL in a foreach Loop, but it´s not working.
...
foreach($sites as $site) {
$URL = $site;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$response = curl_exec($ch);
curl_close($ch);
}
print substr($response, $start, $i);
...
If I use just a single HTTPS-URL I get the Phrase, but inside a foreach-loop it´s not working. Can someone help me? (:
Please excuse my poor english..
this may help :) store result inside an array
$sites = ['https://stackoverflow.com','http://example.org'];
$result = [];
foreach ($sites as $site) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $site);
// User agent
curl_setopt($ch, CURLOPT_USERAGENT, "PHP Curl");
// Include header in result? (0 = yes, 1 = no)
curl_setopt($ch, CURLOPT_HEADER, 0);
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// execute the given URL, and return output
$result[] = curl_exec($ch);
curl_close($ch);
}
var_dump($result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With