codeigniter - Extract value from href tag in table using php -
i have table td below. want extract value "abl" value of symbol href tag.
<td> <a href="../detail.php?symbol=abl">ace bank limited</a> </td>
i can extract ace bank limited using $td->nodevalue; how can extract abl using php only?
try dom
$html = '<td><a href="../detail.php?symbol=abl">ace bank limited</a></td>'; $dom = new domdocument; @$dom->loadhtml($html); foreach ($dom->getelementsbytagname('a') $tag) { $anchor = $tag->getattribute('href'); $text = explode('=', $anchor); echo $text[1]; //abl }
or using preg_match
preg_match('/=([^\"]+)/', $html, $matches); echo $matches[1]; //abl
Comments
Post a Comment