Jegs Posted August 13, 2006 Share Posted August 13, 2006 Hi guysI'm new here! so sorry if this is off topic. I search teh forum if this thread was previously treated, but I didn't find anything.The question is very simple. I'm sending mails throught php with the mail function, and using a plain text file to store the addresses that users have suscribed.The text file has a simple format just like:User1 <user1@domain.com>, User2 <user2@domain.com>The php, reads the text file and associates it whole content to a variable called $to used to send the mail after. The previous formats works ok, but:If for example a user wants to register two addresses how should I format it in the text file. I have tried this:User3 <user3_address1@domain.com, user3_address2@domain.com> but It doesn't work. Anyone could help please :DBest regardsJavier Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted August 13, 2006 Share Posted August 13, 2006 How you format it is really all up to you. It depends on how you're going to parse the file to get the information out.You might want to look into the parse_ini_file() function (http://www.php.net/parse_ini_file), which will take a file in a particular format and return the information in an array.In your case, if you change the format of your file to:[code][user1]email[] = user1@example.com[user2]email[] = user2@example.com[user3]email[] = user3a@example.comemail[] = user3b@example.com[/code]The results of using code something like this:[code]<?php $user_email = parse_ini_file('user_email.txt',true); echo '<pre>' . print_r($user_email,true) . '</pre>';?>[/code]Is an array containing:[code]Array( [user1] => Array ( [email] => Array ( [0] => user1@example.com ) ) [user2] => Array ( [email] => Array ( [0] => user2@example.com ) ) [user3] => Array ( [email] => Array ( [0] => user3a@example.com [1] => user3b@example.com ) ))[/code]Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.