Results 1 to 4 of 4
  1. #1

    exlpode() - probably an easy one

    Hey Guys,

    Usually I give things a shot on my own and then come here when it goes wrong, but I figure its better to ask this one first. Basically, I'm going to have a field in my database that is going to contain a set of emails seperated by commas (or whatever character). Example:

    [email protected],[email protected],[email protected],

    Please note that it will also end in a comma. What I want to do is seperate these so that I can get my hands on each individual email. I know a while loop will probably be involved but was wondering if someone who knows what their doing with the explode() function could show me how its done quickly and I can take it from there.


  2. #2
    Join Date
    Feb 2003
    Just do
    //This puts its in an array
    $csv = "[email protected],[email protected],[email protected],";
    $variable = explode("," $csv);
    Or you can do a loop

    for ($x = 0; $x < count($variable); $x++)
        echo $variable[$x] ."<br>";
    Last edited by keithslater; 05-10-2005 at 09:02 PM.

  3. #3
    Join Date
    Jan 2005
    Assuming $result contains the e-mails you got from the query:
    PHP Code:
    $emails as $email) {
    $email){echo "$email<br />";}

    The "if" statement is optional, but since your string ends with a comma you'll have one null statement at the end.

  4. #4
    awesome, thanks guys. I knew it was simple.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts