Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $el = 'li'; // Ex
- $match = []; // Reserving for results
- /**
- * Regex - extract HTML tag and its content
- * Array map:
- * x[0] = everything
- * x[1] = open tag
- * x[2] = attributes
- * x[3] = content & end tag
- * x[4] = content only
- *
- * Note for content: including text node + children node
- */
- $reg = '/(<'.$el.'(.*?)>)((n*?.*?n*?)</'.$el.'>|)/';
- if (preg_match($reg, $html_str, $match)) { echo 'Moving onward!';}
- $dom = new DomDocument();
- $content = mb_convert_encoding(
- get_the_content(null, true), # WordPress func, it gives input str
- 'HTML-ENTITIES',
- 'UTF-8'
- );
- $dom->loadHTML($content);
- $el = $doc->getElementsByTagName('li');
- <link rel="stylesheet" href="/html_5/tags/html_link_tag_example.css">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement