php - read each line and process

Discussion in 'PHP' started by iamyoohoo, May 26, 2007.

  1. #1
    I have a text area where email addresses will be entered in a separate line. I need to read those one by one and send out an email to each email address

    so for example: the textare may have

    email1@yahoo.com
    email2@hotmail.com
    email3@gmail.com

    I need to be able to read this data one by one and process it using the mail() function. can someone show me how to do that i.e. read each one separately into maybe an array and process it ?

    im kinda new to php. ....
     
    iamyoohoo, May 26, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    
    foreach( split( "\n", $_POST['textarea'] ) as $address )
    {
    //mail etc
    }
    
    PHP:
     
    krakjoe, May 26, 2007 IP