Jump to content


Photo

string find and replace


  • This topic is locked This topic is locked
2 replies to this topic

#1 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 26 July 2006 - 03:33 AM

I am looking to take a string stored in $variable, and search it for the & character, and replace it with '&' without the ' ' before placing into the database.

I find this character breaks the xml feed, and I'd rather not have to edit the database each and every time.

Thanks in advanced to anyone that can help with this trick.

#2 Dville

Dville
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 26 July 2006 - 03:43 AM

// This code will remove the '&' chracters to prevent it from breaking the rss feeds
$oldWord = "&";

// The new word we want in place of the old one
$newWord = "&";

// Run through the text and replaces all occurrences of $oldText
$ArticleBody = str_replace($oldWord , $newWord , $ArticleBody);

figured it out, rock on

#3 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 26 July 2006 - 04:05 AM

htmlentities()
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users