Nodes ToArray - ThomasWeinert/FluentDOM GitHub Wiki

FluentDOM\Nodes::toArray()

array toArray();

Returns the found nodes as an array.

Usage

$xml = <<<XML
<html>
  <head>
    <title>Examples: FluentDOM\Nodes::toArray()</title>
  </head>
<body>
  <p>Hello</p>
  <p>cruel</p>
  <p>World</p>
</body>
</html>
XML;

$nodes = FluentDOM($xml)->find('//p')->toArray();
array_splice($nodes, 1, 1);
echo implode(' ', $nodes);

Output

Hello World
⚠️ **GitHub.com Fallback** ⚠️