Regular expression
Posted: Mon Feb 01, 2010 5:39 pm
Moved by moderator to Regex forum:
Why is preg_match_all getting empty results for this html:
Edit: is
Why is preg_match_all getting empty results for this html:
<div class="info">
<h5>Plot:</h5>
<div class="info-content">
A lawman apprehends a notorious outlaw and gives him 9 days to kill his older brother, or else they'll execute his younger brother. <a class="tn15more inline" href="/title/tt0421238/plotsummary" onClick="(new Image()).src='/rg/title-tease/plotsummary/images/b.gif?link=/title/tt0421238/plotsummary';">full summary</a>
Code: Select all
function get_movie_info($html)
{
preg_match_all('/<h5>Plot:<\/h5>(.*)<a/', $html, $result);
if(isset($result[0])) {
foreach($result[0] as $val) {
echo $val;
}
}else {
echo "result[0] not set<br/>";
}
if(isset($result[1])) {
foreach($result[1] as $val) {
echo $val;
}
}else {
echo "result[1] not set<br/>";
}
}