lawrence_dev
asked on
How do I extract values with pregmatch if located within <UL> tags
How do I correctly structure this pregmatch to get each subcategory name which is only located between <ul> tags.
(I do not want values that are not located within <ul> tags. Is this possible?)
(I do not want values that are not located within <ul> tags. Is this possible?)
<ul>
<li>
<a href="/ammo-case" title="">Case</a>
</li><li>
<a href="/ammo-pistol" title="">Pistol</a>
</li><li>
<a href="/ammo-rifle" title="">Rifle</a>
</li><li>
<a href="/ammo-shotgun" title="">Shotgun</a>
</li></ul>
$statement = $conn->prepare('INSERT INTO SubCats (SubCatName) VALUES(:SubCatName)');
preg_match_all('%<li>\s*<a href=".*?" title="">(.*?)<\/a>\s*<\/li>%si',$buffer1,$matches1);
foreach($matches1[0] as $key=>$link){
$params = array(':SubCatName'=>$matches1[1][$key]);
$statement->execute($params);
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER