我在尝试合并我的xml文件时收到此错误。我读了其他问题和答案,我找不到任何解决方案。我无法增加计算机的内存。这是我的代码
public function mergeXml ($filename,$source){
$events = array();
// open each xml file in this directory
foreach(glob("$source/*.xml") as $files) {
// get the contents of the the current file
$events[] =$files; // throw all files into an array .
}
// Replace the strings below with the actual filenames, add or decrease as fit
$out = new \DOMDocument();
$root = $out->createElement("documents");
foreach ($events as $file) { //get each file from array
$obj = new \DOMDocument();
$obj->load($file); //load files to obj.
$xpath = new \DOMXPath($obj);
foreach ($xpath->query("/*/node()") as $node)
$root->appendChild($out->importNode($node, true)); }
$out->appendChild($root);
file_put_contents("$source/$filename.xml",$out->saveXML());