get some content in file_get_content function [closed]

You’re probably better off using SimpleXML with an XPath query to pull all instances of the tag you want:

$str="
<html>
  <head>
  </head>
  <body>
    <p>one</p>
    <p>two</p>
    <p>three</p>
  </body>
</html>
";

$xml = new SimpleXMLElement($str);
foreach ($xml->xpath('//p') as $item) {
    print_r($item);
}

Leave a Comment