Jump to content

Php preg_match_all problem


sebasjuh

Recommended Posts

Hello,

 

I found this php forum with google in search for an answer to my question. I can't find the answer so I thought maybe I can try it on this forum....

 

This is my question:

I'll have a curl function to get the data from a page, now i'm want the data between the <span class="Title"></span> and the data between the tag <a class='Link'></a>. If I use preg_match_all for the span tag i'll get the results but how can I check on 2 html tags?

 

The code I have is this: (the $result value is the data from the curl command).

Is is possible to make a $pattern with 2 tag's to search for? Or how can I else solve it? Hope someone can help me with it.....

 

$pattern = '/<span\s+(?:.*?\s+)?class=([\"\'])Title\1\s*>\s*(?:.*?\s+)*?(.*?)\s*<\/span>/';

preg_match_all($pattern, $result, $matches, PREG_SET_ORDER);

foreach ($matches as $val) {
echo "Title: $val[0] <br>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/162125-php-preg_match_all-problem/
Share on other sites

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.