Results 1 to 2 of 2

Thread: mutiple str_replace?

  1. #1
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default mutiple str_replace?

    I have tried to enter the str_replace string, but with the last part, in bold, str_replace("example","dd",$text);
    it shows the value of $text, as it should i think.
    now if i do,
    str_replace("example","dd",$text);
    str_replace("dynamic","dd",$text);

    it will print the content of $text 2 times, because (i think) of the $text part....

    how do you stop it from showing the content of $text more than once?

    P.S - Sorry if i have confused you

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    $text = str_replace($find1,$replace1,$text);
    $text = str_replace($find2,$replace2,$text);
    echo $text;


    You need to set something equal to the value of str_replace, not just run it.
    str_replace() by itself is no more productive than running the line "$text;". That won't generate output or change the stringe.

    Then simply use echo when you would like for the new version of $text, and that's it.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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