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.

PHP preg_split -- Will Any Body Help Me To Understand This Simple Line Please --

Discussion in 'PHP' started by actress143, Jun 13, 2010.

  1. #1
    This will adds email ids one by one to database, which are separated with comma,

    there is no error..........! its working good but i need to understand that.

    
    
    $sql="insert into $tbl_name (email) values('". join("'), ('", preg_split('/\s*,\s*/', $email_addresses)). "')";
    
    
    PHP:

    Any body tell me clearly what's happening hear..., please tell me clearly.
    values('". join("'), ('", preg_split('/\s*,\s*/', $email_addresses)). "')";
    PHP:
    i mean why '/\s*,\s*/', and . join("'), ('",

    i am fresher please tell me...., in a clear way. i already read the consept on them but not understand clearly..!
     
    actress143, Jun 13, 2010 IP
  2. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    Why not learn PHP? If it works fine why do you need to understand it.
     
    Pudge1, Jun 13, 2010 IP
  3. actress143

    actress143 Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Dear Pudge1,

    ya came to know that you don't know any thing abut php..., then please don't make any waste comments to increase your posts.. please its my request.
    dont waste your and my time..,

    that's i got from net and working find and now i need to understand.. thats it. ok
     
    actress143, Jun 14, 2010 IP
  4. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #4
    \s* = matches zero or more white space
    , = matches a comma
    \s* = matches zero or more white space
    The preg_split creates an array, so that join takes the array and puts each element one after another into a string, each element being separated by ),(

    so:

    if $email_addresses = 'a1@example.com,a2@example.com';

    Then after the split you have and array:

    [0] =
    [1] =

    Then after the join a string:

    "a1@example.com), (a2@example.com

    Hope that helps.
     
    tolra, Jun 14, 2010 IP
  5. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80