Jump to content

Replacing values in an array


NLCJ

Recommended Posts

Hello,

We get an array from another site, and we convert it to XML for further use. The problem is that special characters result in errors at XML (especially Internet Explorer...) so we have to filter them out, and replace them. This might be a noobish attempt, but I did:

$resultsuncensored = $resp->value();

				$e = array("é", "ë", "ê", "è");
				$resultse = str_replace($e, "e", $resultsuncensored);
				$resultsen = str_replace("&", "en", $resultse);
				$a = array("à", "á", "â", "ã", "ä");
				$resultsa = str_replace($a, "a", $resultsen);
				$results = str_replace("ç", "c", $resultsa);

But no characters get replaced! :( How can I solve this / what am I doing wrong?

 

Regards,

Link to comment
Share on other sites

The most likely cause for the Strange characters would be content encoding.

 

How are you getting this array? Through a HTTP Request?

If you are you most likely to to use htmlentities() to encode the special characters.

 

Also, why would these characters break your XML code? If you can provide us with that information we may not need to replace any data.

 

-cb-

Link to comment
Share on other sites

I'll look up how I get it parsed to my script. But this is the error I get with XML when it has to say something like: à

This page contains the following errors:

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

Link to comment
Share on other sites

I'll look up how I get it parsed to my script. But this is the error I get with XML when it has to say something like: à

This page contains the following errors:

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

Is that from an XML function? Or are you displaying that to a browser?

 

-cb-

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.