Trying to find all HTML <table> rows with this operator, but nothing:
preg_match_all("#<tr[^>]*>.*</tr>#", $content, $matches);
what's wrong?
Trying to find all HTML <table> rows with this operator, but nothing:
preg_match_all("#<tr[^>]*>.*</tr>#", $content, $matches);
what's wrong?
Any regex will have trouble with nested tables, unless you get into complicated recursive expressions.
Try this instead:
$dom = new DOMDocument();
$dom->loadHTML($content);
$matches = $dom->getElementsByTagName("tr");
$count = $matches->length;
$matches is a DOMNodeList, each node has a property childNodes which is another DOMNodeList of its children.