phpnewbie112 Posted July 1, 2008 Share Posted July 1, 2008 Hello, I tried to look around the forum but didn;t find the appropriate answer. I have a txt document with 20 emails 1 email per line acting as a csv file. my code open the csv file $filename = "myfile.txt"; $handle = fopen("myfolder/{$filename}", 'r'); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { echo $data[0]; //to check the output sendmail function to $data[0] } but it is only seing the 1st email and not looping throughout the list to send an email to each email. could you pls adivce. thanks Link to comment https://forums.phpfreaks.com/topic/112824-solved-email-to-csv-list/ Share on other sites More sharing options...
ag3nt42 Posted July 1, 2008 Share Posted July 1, 2008 try while(! feof($filename)) { echo (fgets($filename)); } if it outputs all the lines.. then add your other functionality to it. Link to comment https://forums.phpfreaks.com/topic/112824-solved-email-to-csv-list/#findComment-579489 Share on other sites More sharing options...
phpnewbie112 Posted July 1, 2008 Author Share Posted July 1, 2008 the problem is with the output, results are near each other and not on separate lines Link to comment https://forums.phpfreaks.com/topic/112824-solved-email-to-csv-list/#findComment-579525 Share on other sites More sharing options...
ag3nt42 Posted July 1, 2008 Share Posted July 1, 2008 so are saying that they just arn't lining up right when you echo them out? if so how do u want them? Link to comment https://forums.phpfreaks.com/topic/112824-solved-email-to-csv-list/#findComment-579635 Share on other sites More sharing options...
phpnewbie112 Posted July 2, 2008 Author Share Posted July 2, 2008 we can line them up with an echo <br> but the problem is with the loop throughout all emails. Link to comment https://forums.phpfreaks.com/topic/112824-solved-email-to-csv-list/#findComment-580267 Share on other sites More sharing options...
ag3nt42 Posted July 2, 2008 Share Posted July 2, 2008 your code only allows for 1000 bytes then stops while (($data = fgetcsv($handle, 1000, ",")) !== FALSE change to this: while(!feof($handle)) { $data=fgetcsv($handle); echo($data.PHP_EOL); } Link to comment https://forums.phpfreaks.com/topic/112824-solved-email-to-csv-list/#findComment-580351 Share on other sites More sharing options...
phpnewbie112 Posted July 3, 2008 Author Share Posted July 3, 2008 the code shows nothing, it take around 3 minutes for the page to load but no results, empty page ??? Link to comment https://forums.phpfreaks.com/topic/112824-solved-email-to-csv-list/#findComment-580691 Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 What separates the email addresses? A comma, a space, a newline? Link to comment https://forums.phpfreaks.com/topic/112824-solved-email-to-csv-list/#findComment-580692 Share on other sites More sharing options...
phpnewbie112 Posted July 4, 2008 Author Share Posted July 4, 2008 a newline Link to comment https://forums.phpfreaks.com/topic/112824-solved-email-to-csv-list/#findComment-581573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.