I'm building an application that will read a a text file that has URLs of sequentially numbered images, retrieve the images, and zip them for download. The first part of the script checks weather or not the image files actually exist, this is where I run into problems. The script is suppost to halt when a file doesen't exist, however, it's halting on the the first file eventhough it exists. Can someone please explain what I'm doing wrong?
<?php
/*
* Read the contents of a text file into an array. Format the array so
* that only the PNG image URL's are present.
*
* Array
* (
* [0] => http://s17.postimg.org/cbxg8kf71/000.png
* [1] => http://s17.postimg.org/d2q6echkd/001.png
* [2] => http://s17.postimg.org/r6m1mqorx/002.png
* [3] => http://s17.postimg.org/tf0842vvx/003.png
* [4] => http://s17.postimg.org/vm925qqjx/004.png
* [5] => http://s17.postimg.org/808ujk8a5/005.png
* [6] => http://s17.postimg.org/d5aikk25p/006.png
* [7] => http://s17.postimg.org/64hxe1azx/007.png
* [8] => http://s17.postimg.org/ymh6e6419/008.png
* [9] => http://s17.postimg.org/rtgthwd7x/009.png
* [10] => http://s17.postimg.org/wvy5comi5/010.png
* [11] => http://s17.postimg.org/dterprbhp/011.png
* [12] => http://s17.postimg.org/n55f0gdf1/012.png
* )
*
* Contents of ./Comics/Prime Apes (2014)/000.txt can be found at:
* https://www.dropbox.com/s/n9drgy8948on5w4/Prime.Apes.%282014%29.000.txt
*/
$lines = file("./Comics/Prime Apes (2014)/000.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$gallery = array_shift($lines);
/*
* For each array value check weather or not the file exists.
*/
foreach ($lines as $line) {
if (!file_exists($line)) {
exit("{$line} does not exist");
}
}
#print_r($lines);
?>