Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Reply to Thread

Post a reply to the thread: PHP find and replace. Please help?

Your Message

Click here to log in

What color is our footer?

 
 

You may choose an icon for your message from this list

Additional Options

  • Will turn www.example.com into [URL]http://www.example.com[/URL].

Rate Thread

You may rate this thread from 1-star (Terrible) to 5-stars (Excellent) if you wish to do so.

Topic Review (Newest First)

  • 12-12-2010, 04:11 AM
    Jerry

    PHP find and replace. Please help?

    <?php
    // The text string
    $text = "The quick brown fox jumped over the lazy dog.";
    // The word we want to replace
    $oldWord = "brown";
    // The new word we want in place of the old one
    $newWord = "blue";
    // Run through the text and replaces all occurrences of $oldText
    $text = str_replace($oldWord , $newWord , $text);
    // Display the new text
    echo $text;
    ?>

    The current code will only replace one word. I need a code that will replace multiple word. Please help.

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •