-1
我在同一个目录中有三个类似的内置xml文件(编号og文件将随时间变化)。我想在eny的目录中创建一个所有xml文件的数组,并使用glob函数实现此目的 - 我可以这样做。然后我想循环这个新的合并的xml文件 - 但使用下面的代码只能获得后面的文件。我不知道什么是错:使用glob将多个xml文件合并为一个文件
$pastscores = glob('xml/score/*xml');
foreach($pastscores as $output) {
$pastscore = file_get_contents($output);
}
在我的XML文件作为例子看起来之下:
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<SECTION>
<SEASONNO>7</SEASONNO>
</SECTION>
</ROOT>
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<SECTION>
<SEASONNO>6</SEASONNO>
</SECTION>
</ROOT>
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<SECTION>
<SEASONNO>5</SEASONNO>
</SECTION>
</ROOT>
$ pastscore。= file_get_contents($ output); http://php.net/manual/en/language.operators.string.php –
请分享您的预期输出,并分享您尝试过的代码。 –
@ mr.void串联会追加'<?xml version =“1.0”encoding =“utf-8”?>'三次。 –