ballouta Posted December 27, 2008 Share Posted December 27, 2008 Hi, I have this piece of code to pull up data from a text file, and it is working properly, Each line is actually an email address, I want to send a message for this email address. my Question is: A.Why we are printing $fields[0] $fields[2] and NOT $fields[$k]? although the out put is correct. B. And if i am using the mail fuction does this seem correct: mail('$fields[0] $fields[2]', $subject, $message, $headers); <?php $readfile = file("files/$output"); for ($k=0; $k<=count($readfile)-1; $k++) { $fields = split("\t",$readfile[$k]); print("$fields[0] $fields[2]<br>"); // this is working too ?> Thank you Link to comment https://forums.phpfreaks.com/topic/138539-array-question/ Share on other sites More sharing options...
kenrbnsn Posted December 27, 2008 Share Posted December 27, 2008 Why we are printing $fields[0] $fields[2] and NOT $fields[$k]? although the out put is correct. $k is incrementing through the array. You're splitting each line into fields and only need the 1st & 3rd field. And if i am using the mail fuction does this seem correct: <?php mail('$fields[0] $fields[2]', $subject, $message, $headers); ?> Without knowing what the data in your file looks like, we can't answer this question. Ken Link to comment https://forums.phpfreaks.com/topic/138539-array-question/#findComment-724348 Share on other sites More sharing options...
ballouta Posted December 27, 2008 Author Share Posted December 27, 2008 my text file always contain email addresses in this format [email protected] [email protected] and i don't need to split each line thanks again Link to comment https://forums.phpfreaks.com/topic/138539-array-question/#findComment-724355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.