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.

Help with preg_match_all

Discussion in 'PHP' started by alinask, Jan 21, 2010.

  1. #1
    Hi. I'm trying to use preg_match_all in order to get the string between " " , that work's for new lines too. For example, if i have the

    $string='this is "my string " and i want parse the value into an array. \n and "another string" too. ';

    and
    preg_match_all('expresion', $string, $matches);

    After that ,
    matches[0]=my string
    matches[1]=another string

    and so on. Please help my guys with right expresion, i need it a lot.

    Thank You
     
    alinask, Jan 21, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    $matches = explode("\n", $string);
    PHP:
    Regex is not necessary.
     
    danx10, Jan 21, 2010 IP
  3. alinask

    alinask Active Member

    Messages:
    330
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Done

    If you are intereseted, this is the expresion


    preg_match_all('/"(.*)?"/iU', $a, $matches);


    Thank's danx'10 anyway
     
    alinask, Jan 21, 2010 IP
  4. xenon2010

    xenon2010 Peon

    Messages:
    237
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    $pattern = '/\"([^\"]*)\"/s';

    this is not tested though..
     
    xenon2010, Jan 21, 2010 IP
  5. unigogo

    unigogo Peon

    Messages:
    286
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    unigogo, Jan 22, 2010 IP
    alinask likes this.
  6. alinask

    alinask Active Member

    Messages:
    330
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #6
    @unnigogo you're right

    thank you
     
    alinask, Jan 22, 2010 IP