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
https://forums.phpfreaks.com/topic/166180-solved-preg_match_all-no-results/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.