kevinkhan
10-27-2009, 03:23 PM
Hi Guys,
I want to get the href and title out of this html code below..
<li class="images"><a href="www.something.com/firstpage/" title="title1"><span>7</span></a></li>
I set the html code as a string
$strContent= "<li class="images"><a href="www.something.com/firstpage/" title="title1"><span>7</span></a></li>";
and set up this funtion with the regular expression below
$strListMatches = '!<li class="images" href="(.*)" title="(.*)"><span>(.*)</span</a></li>!isU';
function getMatches($strMatch,$strContent)
{
if(preg_match_all($strMatch,$strContent,$objMatches))
{
return $objMatches;
}
return "";
}
i tryed this piece of code to print the title but it wont work.
print_r($objListMatches[1]);
Is there something wrong with the regular expression?
iv tryed this regular expression but it wont work :(
$strListMatches = '!<li class="images" href="(.*)" title="(.*)"><span>(.*)</span></a></li>!isU';
I want to get the href and title out of this html code below..
<li class="images"><a href="www.something.com/firstpage/" title="title1"><span>7</span></a></li>
I set the html code as a string
$strContent= "<li class="images"><a href="www.something.com/firstpage/" title="title1"><span>7</span></a></li>";
and set up this funtion with the regular expression below
$strListMatches = '!<li class="images" href="(.*)" title="(.*)"><span>(.*)</span</a></li>!isU';
function getMatches($strMatch,$strContent)
{
if(preg_match_all($strMatch,$strContent,$objMatches))
{
return $objMatches;
}
return "";
}
i tryed this piece of code to print the title but it wont work.
print_r($objListMatches[1]);
Is there something wrong with the regular expression?
iv tryed this regular expression but it wont work :(
$strListMatches = '!<li class="images" href="(.*)" title="(.*)"><span>(.*)</span></a></li>!isU';