note 83630 deleted from class.domnodelist by joey
| From: | joey@php.net | Date: | Tue, 16 Oct 2012 00:55:09 +0000 |
| Subject: | note 83630 deleted from class.domnodelist by joey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191314@lists.php.net to get a copy of this message | ||
Note Submitter: mark at codedesigner dot nl
----
$newNode = $dom->createElement('newNode') ;
foreach ($nodeList as $node) {
echo $node->nodeValue ;
$newNode->appendChild($node) ;
}
the problem lies with the fact that foreach works on a copy of your object. The solution is simple,
add & to $node
$newNode = $dom->createElement('newNode') ;
foreach ($nodeList as &$node) {
echo $node->nodeValue ;
$newNode->appendChild($node) ;
}