Change some words in a feed

Discussion in 'PHP' started by Adbie.for.ever, Nov 26, 2008.

  1. #1
    Hey Co - Webmasters,

    Sinds last week I tried to make a script (in php with some sql)
    that can rewrite a feed so that some words change automatic.
    And that the new feed can put in web 2.0 app like netvibes.

    Example: Rss Feed - attendance at special course
    To Feed - to be there at special course

    Is it difficult to make something? I tried but with no success.
    I hope that someone know how it can work.
     
    Adbie.for.ever, Nov 26, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    It's not difficult, but takes some time.

    Create an array with words to search for and words to replace

    for example
    
    $text = 'the bad line that needs to change words';
    $arr = array("word" => "new-ord", 
                     "bad" => "good",
                     "true" => "false");
    
    foreach ($arr AS $search => $replace)
    {
        // replaces words / multiple words
        $text = str_replace($search, $replace, $text);
    }
    
    Code (markup):
    hope this works for you!
     
    EricBruggema, Nov 28, 2008 IP