Let us have an array:

array(1) { [0]=> string() "Нерабочая ссылка на картинку" [1]=> string() "Рабочая ссылка на картинку" ... } 

You need to start brute forceing it, in case the picture does not exist on the link - skip and move on, if there is then print save on the server (copy).

  • It will be more convenient to rasparralelit it, rather than waiting for the end of each scan linearly. - Daniel Protopopov

1 answer 1

I think you need to dig in the direction of file_get_contents , something like: do brute force the array until the return value of the function is different from false - this will be the picture.

Documentation - http://php.net/manual/ru/function.file-get-contents.php

Example:

 foreach($links as $link){ if(($result = file_get_contents($link)) !== false){ break; } } 
  • Can you give an example? I do not quite understand how to do this sorting, which continues to iterate further in the case of false - Coffee inTime
  • foreach ($ links as $ link) {if (($ result = file_get_contents ($ link))! == false) {break; }} Something like this - manowartop
  • @Andrey Dobrovolsky, you can click "edit" and add your code in response - Ep1demic