我想XML标记之间的所有单词从阵列和目前的结果是:从XML检索文本?
注意:数组字符串转换在........在线84
结果是:数组
if(isset($_POST['send']))
{
echo "sync is started <br>";
$handle = fopen("XML/$file_name", "r");
if ($handle)
{
while (($line = fgets($handle)) !== false)
{
$keywords=array("series_title","series_type","series_episodes");
for ($i=0; $i < 3; $i++)
{
$pattern = "/<$keywords[$i]>(.*?)<\/keywords[$i]>/";
preg_match($pattern, $line, $matches);
echo "result is: " . $matches . "<br>";
}
}
}
else
{
$upload_text = "error";
}
$upload_text ="finished";
fclose($handle);
//unlink('XML/' . $file_name);
}
难道您发布的原始数据的一个例子,你试图解析,是否有任何理由,而不是使用XML解析器? – Prix 2014-10-07 21:17:18
你正在尝试回显'$ matches'这是一个数组。您需要遍历并打印阵列中找到的每个匹配项 – ElefantPhace 2014-10-07 21:19:38
$ matches是一个数组,因此您可以这样做:'echo“结果为:”。 implode(“,”,$ matches)。 “
”;'但是真的,使用SimpleXML看看http://php.net/manual/en/intro.simplexml.php – dave 2014-10-07 21:19:52