Checking for a Banner on Page

Discussion in 'PHP' started by projectWORD, Aug 3, 2008.

  1. #1
    Hi,
    Can someone help me out with the patern matching part of my script. I basically want to check if my banner is on the page. So I get the page into contents then need to do a pattern matching. The code is:-

    $text = file_get_contents($url);

    if (!empty($text)) {
    //This is where the pattern match has to be
    );

    I want to match this:-

    <a href="http://www.projectword.co.uk" title="Linking Keywords to your Websites" target="_blank" ><img src="http://www.projectword.co.uk/images/banprom/120x60.png" border="0"/></a>

    Maybe using a preg_match_all or something.
    Thanks in advance
     
    projectWORD, Aug 3, 2008 IP
  2. Hallent

    Hallent Peon

    Messages:
    65
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if (preg_match("/href=\"(http\:\/\/www\.projectword\.co\.uk)\"/iU",$text,$match)) {
        echo 'worked';
    } else {
        echo 'didnt work';
    }
    PHP:
     
    Hallent, Aug 3, 2008 IP
  3. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #3
    If it's that exactly that string, use:

    
    if (stristr($text, '<a href="http://www.projectword.co.uk" title="Linking Keywords to your Websites" target="_blank" ><img src="http://www.projectword.co.uk/images/banprom/120x60.png" border="0"/></a>')){
        echo "Found";
    } else {
        echo "Not Found";
    }
    
    PHP:
    Jay
     
    jayshah, Aug 3, 2008 IP