Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function getTextBetweenTags($tag, $html){
- $dom = new domDocument;
- $dom->loadXML($html);
- $dom->preserveWhiteSpace = false;
- $content = $dom->getElementsByTagname($tag);
- $out = array();
- foreach ($content as $item){
- $out[] = $item->nodeValue;
- }
- return $out;
- }
- $html = '<html>
- <body>
- <para>1</para>
- <para>2</para>
- </body>
- </html>';
- $content = getTextBetweenTags( 'para',$html);
- foreach($content as $item ){
- echo $item.'<br>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement