Php 替换字符串isn';行不通

Php 替换字符串isn';行不通,php,xml,string,replace,Php,Xml,String,Replace,我有两个数组,一个包含要替换的字符,一个包含要替换的字符: $charToReplace = array("é", "è", "ê"); $charReplacements = array("e", "e", "e"); 我循环查询的结果,当我到达Artister_name字段时,我想替换数组中的字符。我试着这样做,但这让我犯了一个错误: $itemrow['artist_name'] = str_replace($charToReplace, $charReplacements, $item

我有两个数组,一个包含要替换的字符,一个包含要替换的字符:

$charToReplace = array("é", "è", "ê");
$charReplacements = array("e", "e", "e");
我循环查询的结果,当我到达Artister_name字段时,我想替换数组中的字符。我试着这样做,但这让我犯了一个错误:

$itemrow['artist_name'] = str_replace($charToReplace, $charReplacements, $itemrow['artist_name']);
这是我收到的错误:

此页面包含以下错误:

第9列第29行出错:编码错误 下面是第一个错误之前的页面呈现

这是php生成的xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<artists>
<artist>
    <id>855</id>
    <name>Have Heart</name>
    <picture>http://userserve-ak.last.fm/serve/126/29086375.jpg</picture>
    <twitter></twitter>
</artist>
<artist>
    <id>856</id>
    <name>Carpathian</name>
    <picture>http://userserve-ak.last.fm/serve/126/50284337.jpg</picture>
    <twitter></twitter>
</artist>
<artist>
    <id>857</id>
    <name>Deftones</name>
    <picture>http://userserve-ak.last.fm/serve/126/2203330.jpg</picture>
    <twitter></twitter>
</artist>
<artist>
    <id>858</id>
    <name>Converge</name>
    <picture>http://userserve-ak.last.fm/serve/126/29640629.jpg</picture>
    <twitter></twitter>
</artist>
<artist>
    <id>859</id>
    <name>Touchrtist>
    <id>878</id>
    <name>True Colors</name>
    <picture>http://userserve-ak.last.fm/serve/126/46942947.jpg</picture>
    <twitter></twitter>
</artist>

855
忍心
http://userserve-ak.last.fm/serve/126/29086375.jpg
856
喀尔巴阡山脉
http://userserve-ak.last.fm/serve/126/50284337.jpg
857
盲音
http://userserve-ak.last.fm/serve/126/2203330.jpg
858
会聚
http://userserve-ak.last.fm/serve/126/29640629.jpg
859
Touchrtist>
878
真面目
http://userserve-ak.last.fm/serve/126/46942947.jpg

第一个是正确的,但最后一个坏了。它应该是Touché,但不知何故,它会在一段时间后中断并继续。

该错误是由浏览器输出的,而不是由PHP输出的。这可能意味着您告诉浏览器将站点解释为严格的XHTML,并且您的XML中存在错误,因此浏览器停止解析它。这并没有说明您显示的PHP代码。

您的代码是PHP,您的问题被标记为ActionScript?@weltraumpirat Haha,我本来打算更改它,但我不确定它是否因为其他不可预见的原因被标记为3:PTo添加到此:第29行包含以下内容:
Touchrtist>
,这是格式不正确的XML。它应该是
touchrist