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.

preg_match_all to grab a form?

Discussion in 'PHP' started by mokimofiki, Oct 12, 2012.

  1. #1
    I am trying to pull the get it now button from daily steals homepage but it doesn't seem to work.

    [WORKS]Pulling the title works fine like this:
    preg_match_all("'<h2>(.+?)<\/h2>'",$content,$matches);
    foreach($matches[0] as $match){ $stealtitle[] = $match; }
    $todaysstealtitle = $stealtitle[0];
    Code (markup):
    [NOT WORKING]Pulling the form finds nothing like this:
    preg_match_all("'<form class=\"submit\" id=\"getitform\"(.+?)<\/form>'",$content,$matches);
    foreach($matches[0] as $match){ $stealgetit[] = $match; }
    $gettodayssteal = $stealgetit[0];
    Code (markup):
    Any advice would be greatly appreciated as its frustrating me (probably a comma or something out of place lol)

    Thank you in advance
     
    Solved! View solution.
    mokimofiki, Oct 12, 2012 IP
  2. #2
    I assume its because its multiline

    I would do it like this

    
    // remove line feeds
    $content = str_replace("\n",'',$content);
    
    preg_match_all('|<form class="submit" id="getitform"(.+?)<\/form>|',$content,$matches);
    
    foreach($matches[0] as $match){
       $stealgetit[] = $match; 
    }
    
    $gettodayssteal = $stealgetit[0];
    
    
    PHP:
    good luck
     
    plussy, Oct 12, 2012 IP
  3. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #3
    I love you, thank you it worked perfectly :)

    (tried to give you +rep but apparently I did in a previous post and it wants me to spread the love somewhere else first)
     
    mokimofiki, Oct 12, 2012 IP