I need help with one snippet of code that has me ready to explode, involving an automatically downloaded zip folder for an external URL, containing just a single txt file, that I will upload to a mysql database, to complete a project I've been working on for five years.
The short version is I need to get the daily text file from this url:
http://batstrading.com/market_data/shortsales/2014/06/BYXXshvol20140620.txt.zip-dl?mkt=byx
I have tried everything, in a hundred combinations. On those occasions no errors occurred, there were no txt files created nor uploaded to the db , permissions set to 777
zip_open, zip_read, zip_entry_open, zip_entry_read, fgets, fopens, file_get_contents
The long version with a valid url is:
function getBATStxtfile($BATSzipurlFile, $BATSZoutputFile)
{
$BATSzipurl="http://batstrading.com/market_data/shortsales/2014/06/BYXXshvol20140620.txt.zip-dl?mkt=byx";
file_get_contents($BATSzipurl);
$batstxtzipFile=zip_open($BATSzipurl);
$batstxtzipFile=zip_read($BATSzipurl);
$batstxtFile = zip_entry_open($batstxtzipFile;
$batstxt = zip_entry_read($batstxtFile);
$batstxt = str_replace("Date|Symbol|Short Volume|Total Volume|Market Center", "",$batstxt);
$batstxt = str_replace("|", ",", $batstxt);
$batstxt = trim($batstxt);
file_put_contents($BATSZoutputFile, $batstxt);
zip_entry_close($batstxtFile);
zip_close($BATSzipurl);
}
I have 3000000 lines of code, 10,000 failed scripts, and all I need to have my life back...is this .txt file retrieved. Thank you in advance.