2016-01-27 00:54



I haven't worked with preg_match() too terribly much but I can not figure out why searching for 1 div like this:

$div = '<div class="ipsPageHeader ipsClearfix">';
preg_match("/".$div."(.*?)<\/div>/", $html, $matches); $content=md5($matches[0]);

But when I try to search for a div different div like this:

$div = '<div class="cPost_contentWrap ipsPad">';
preg_match("/".$div."(.*?)<\/div>/", $html, $matches); $content=md5($matches[0]);

It gives me this error message:

Notice: Undefined offset: 0 in C:\xampp\htdocs\Freelancer\citrix\steam.php on line 33

If you're curious what page I'm pulling from it's Here

Basicaly, I'm taking the top post of this page to save and compare later to see if there have been changes

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • duande1985 duande1985 5年前

    On that particular page, there is no <div class="cPost_contentWrap ipsPad">, only <div class='cPost_contentWrap ipsPad'>. Notice that the one on the page uses single-quotes, while your regular expression uses double-quotes, meaning that the characters don't match and the search returns no results.

    点赞 评论 复制链接分享