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?
preg_match_all ('#<tr[^>]*>(.*?)</tr>#s')
Added the "s" flag, so that it also matches newlines, a question mark to the match (lazy), and also added parenthesis (to capture the group).
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;