#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Eindhoven, NL
    Posts
    22
    Rep Power
    0
    I use a form to collect emailadresses (form name=email) and the idea is that you can enter multiple adresses comma seperated.

    Now my question is, how do I split the emailadresses and put them seperated in my dbase. I know I have to use (some of) the commands mentioned in the topic, but I couldn't find any good example that made me understand how it works...

    Anyone?
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    how do I split the emailadresses and put them seperated in my dbase.
    >>


    You can use explode() function for this..

    try something like this...

    <?
    $emails="shiju@post.com,myjesus@hotbot.com,jesus_jerusalem@hotmail.com";
    //email addresses..

    $email_values=explode(",",$emails);
    //seperate the values based on "," and put it in an array..

    // now you can insert the value into the database..

    for($a=0;$a<count($email_values);$a++){

    mysql_query("INSERT INTO tablename(email) values('$email_values[$a]')";
    //insert the emaiils..

    }
    ?>


    Good Luck!!

    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited August 07, 2000).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    London/UK
    Posts
    91
    Rep Power
    15
    the only difference (as far as I can tell) between explode() and split() is that explode uses less overheads as you cannot specify regexps in them, I may be wrong on this though

    something like this shows how explode is really cool

    $random_incoming_string = "myname,myaddress,mytel,myemail";

    list($name,$address,$telephone,$email) = explode(",",$random_incoming_string);

    bealers

    ------------------
    http://back-end.org
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    You are right. split() uses regexps and is a little slower. explode() doen't. For this use, explode() is perfect...
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Eindhoven, NL
    Posts
    22
    Rep Power
    0
    Thnx ppl

IMN logo majestic logo threadwatch logo seochat tools logo