Jump to content

[SOLVED] preg_match_all no results


dose

Recommended Posts

its been racking my brain for about a week now. im still pretty new to php but ive ask my friend the same question and he cant tell me the reason so hope someone here can figure it out..

 

Im using cURL to get the contents of another site I.E stats from a server.

 

im using

 

preg_match_all("/<div class=\"ep_stat_top_stats_row_right\">(.*?)<\/div>/", $html, $matches);

$bah = $matches['0'];

print_r($bah);

 

to try and match whats between these tags

 

<div class="ep_stat_top_stats_row_right">
                                       250
                                 </div>

 

everytime i try this i just get a blank array back if i echo the $html i do get the full page displaying everything i am trying to grab. So im not to sure what the problem could be.

Link to comment
Share on other sites

if (preg_match('%<div class="ep_stat_top_stats_row_right">(.*?)</div>%si', $html, $matches)) {
$bah = $matches[1];

 

Use the S modifier (dot matches new lines)

 

EDIT: oops forgot to add a match_all example.. (same idea)

preg_match_all('%<div class="ep_stat_top_stats_row_right">(.*?)</div>%si', $html, $matches);

 

EDIT #2: And Welcome to PHP Freaks  :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.