SteveDoig Posted May 2, 2008 Share Posted May 2, 2008 If I run the following code: <?php $row = 1; $fp = fopen ("images.csv","r"); while ($data = fgetcsv ($fp, 20, ",")) { echo $data; $row++; } ?> I get the following output: ArrayArrayArrayArrayArrayArrayArrayArray etc In the images.csv file is a list of jpg filenames, with filenames no longer than 9 characters long, meaning the total row length is no longer than 13 characters. eg. 123456.jpg P1234567.jpg Why is the CSV file not being read properly? Link to comment https://forums.phpfreaks.com/topic/103817-fgetcsv-oddity/ Share on other sites More sharing options...
mrdamien Posted May 2, 2008 Share Posted May 2, 2008 Its is being read properly. PHP.NET tells you that the returned valued is an indexed array containing the fields read. <?php $row = 1; $fp = fopen ("images.csv","r"); while ($data = fgetcsv ($fp, 20, ",")) { for($i=0; $i<count($data); $i++){ echo $data[$i]; } $row++; } ?> Link to comment https://forums.phpfreaks.com/topic/103817-fgetcsv-oddity/#findComment-531515 Share on other sites More sharing options...
SteveDoig Posted May 2, 2008 Author Share Posted May 2, 2008 Okay thanks. I want to download some remote images onto my own remote server. <?php $row = 1; $fp = fopen ("images.csv","r"); while ($data = fgetcsv ($fp, 20, ",")) { $BLA = 'http://www.bla.com.au/images/ProductGroup/' . $data[1]; $download = '/home/hi/hil/hillarysboatshop.com.au/public/www/images/downloads/' . $data[1]; if (!copy($BLA, $download)) { echo "failed to copy $BLA...\n"; } $row++; } This is timing out. Can you suggest a better method? Link to comment https://forums.phpfreaks.com/topic/103817-fgetcsv-oddity/#findComment-531536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.