Veltar
Veltar

Reputation: 741

replace strings isn't working

I have two arrays, one with the characters to be replaced, one with the characters to replace them:

$charToReplace = array("é", "è", "ê");
$charReplacements = array("e", "e", "e");

I loop through the result of a query as such, and when I reach the artist_name field, I want to replace the character if it is in the array. I try to do it like this, but that gets me an error:

$itemrow['artist_name'] = str_replace($charToReplace, $charReplacements, $itemrow['artist_name']);

this is the error I receive:

This page contains the following errors:

error on line 29 at column 9: Encoding error Below is a rendering of the page up to the first error.

this is the xml-code generated by php:

<?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>

The first ones are correct, but the last one breaks. It should say Touché, but somehow it breaks and continues after a while.

Upvotes: 0

Views: 79

Answers (1)

deceze
deceze

Reputation: 522042

That error is output by your browser, not by PHP. It likely means you are telling your browser to interpret the site as strict XHTML and that you have an error in your XML, so the browser stops parsing it. This doesn't say anything about the PHP code you show.

Upvotes: 1

Related Questions