Jump to content

str_replace() issues


11t1

Recommended Posts

I'm having issues when trying to parse an XML feed via PHP. I'm getting it to display alright, but there are embedded images in the XML, like <img src="whatever"> and so when it renders as HTML it prints the tags to the screen, not the images.

 

I tried this:

 

$newdesc0 = $item['description'];

$newdesc1 = str_replace("<", "\<", $newdesc0);

$newdesc2 = str_replace(">", "\>", $newdesc1);

 

and about a hundred permutations thereof to no avail. Where am I going wrong?

Link to comment
Share on other sites

Thank you, indeed. I wasn't even aware of that function.

 

Now that I've slept a bit, I realize I was working on the wrong include file (they have deceptively similar names), but this solution's more elegant than the one I was thinking of.

 

Much appreciated.

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.