title: How to convert DOMNodeList object into array
body: <p>I have this code:</p>
  
  <pre><code>     $dom = new DOMDocument();
       $dom-&gt;load('file.xml');
       $names = $dom-&gt;getElementsByTagName('name');
  </code></pre>
  
  <p>Now, <code>$names</code> is DOMNodeList object, I need to convert this object into an array, </p>
  
  <pre><code>     $names = (array)$names;
       var_dump($names);  // empty array
  </code></pre>
  
  <p>The above code does not work and returns an empty array, why?</p>