1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

While

Discussion in 'PHP' started by strgraphics, Jun 22, 2010.

  1. #1
    In this i thought that it is better to use do while.., do is for calculating the input emails form form, and while for displaying..


    While is the best but check what i done now...!

    <?php
    
    $email=$_POST['mal'];
    
    $emailnumber = 2;
    
    $st = preg_split('/\s*,\s*/', $email);
    
    for ($i=0; $i<=$emailnumber; $i++)
    {
    print_r("$st[$i]");
    echo "<br>";
    }
    ?>
    PHP:
    if $_POST['mal'] having 1000 emails separating with comma ( , ) just like
    ,

    how can i write for loop..,
    i mean at $i<=$emailnumber ($i<=2) i have given for example 2.., it is working but what if i give 1000,

    dont say $i<=1000 hahah,.., just i am saying for example.. 1000,

    How can i calculate $emailnumber number from the input form..,

    i have one idea that..,
    first i have to check how many @ are there in that $_POST['mal'] then we can assign the $emailnumber, but i dont know how to do that as i am not expert.., i am just learner..

    SEMrush
    Thanks for your help....!
     
    Last edited: Jun 22, 2010
    strgraphics, Jun 22, 2010 IP
    SEMrush
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    <?php
    $email = $_POST['mal'];
    $emailnumber = substr_count($email, '@');
    ?>
    PHP:
    or:

    <?php
    $email = $_POST['mal'];
    $emailnumber = sizeof(explode(',', $email));
    ?>
    PHP:
    But if your wanting to be more accurate, you could use preg_match() with a regex to validate an email and then count the matches to give the $emailnumber.
     
    danx10, Jun 22, 2010 IP
    strgraphics likes this.
  3. strgraphics

    strgraphics Active Member

    Messages:
    711
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Ohh k k., thanks a lot friend..,

    i want to say this.., the answers from danx10 are always almost perfect.....!
    i am not blaming others.., just saying ...,


    Thanks dear.! and thanks to allllll
     
    strgraphics, Jun 22, 2010 IP