How not to run a PHP script, provided that the processed TXT file is empty?

There is php code that checks proxies from a file gotovo_vse_sellery_bezdybley.txt and saves the results to a file proxyuniq.txt.

How to get the following script to refuse to run if the source file gotovo_vse_sellery_bezdybley.txt does not contain any information - text (string proxy).

$proxies = file ("gotovo_vse_sellery_bezdybley.txt");
$proxies_out = array();
$mc = curl_multi_init ();
for ($thread_no = 0; $thread_no<count ($proxies); $thread_no++)
$c [$thread_no] = curl_init ();
curl_setopt ($c [$thread_no], CURLOPT_URL, "");
curl_setopt ($c [$thread_no], CURLOPT_HEADER, 0);
curl_setopt ($c [$thread_no], CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($c [$thread_no], CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($c [$thread_no], CURLOPT_TIMEOUT, 10);
curl_setopt ($c [$thread_no], CURLOPT_PROXY, trim ($proxies [$thread_no]));
curl_setopt ($c [$thread_no], CURLOPT_PROXYTYPE, 0);
curl_multi_add_handle ($mc, $c [$thread_no]);

do {
while (($execrun = curl_multi_exec ($mc, $running)) == CURLM_CALL_MULTI_PERFORM);
if ($execrun != CURLM_OK) break;
while ($done = curl_multi_info_read ($mc))
$info = curl_getinfo ($done ['handle']);
if ($info ['http_code'] == 301) {
echo trim ($proxies [array_search ($done['handle'], $c)])."\r\n";
$proxies_out[trim($proxies[array_search($done['handle'], $c)])] = trim($proxies[array_search($done['handle'], $c)]);
curl_multi_remove_handle ($mc, $done ['handle']);
} while ($running);
curl_multi_close ($mc);
file_put_contents("proxyuniq.txt", implode("\r\n", $proxies_out));
April 19th 20 at 12:27
1 answer
April 19th 20 at 12:29
Well, you have already sovseeem.... lazy!
$proxies = file ("gotovo_vse_sellery_bezdybley.txt");
if (empty($proxies))
$proxies_out = array();
thank you. it worked! - jailyn72 commented on April 19th 20 at 12:32

Find more questions by tags PHP