Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple Replaces

    I am trying to replace multiple strings on the same page but having problems. Only one seems to work... is there another function for this?

    PHP Code:
    $row[0] = str_replace("&","and",$row[0]);
    $row[0] = str_replace("/","or",$row[0]); 
    Also, I need it to put everything back to normal on the next page.

    PHP Code:
    $row[0] = str_replace("and","&",$row[0]);
    $row[0] = str_replace("or","/",$row[0]); 

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just create two arrays with the complementary values. like


    $symbol = array('&', '/', '@');
    $word = array('and', 'or', 'at');

    and then you can do

    $row[0] = str_replace($symbol, $word, $row[0]);

    and back

    $row[0] = str_replace($word, $symbol, $row[0]);
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    New Coder
    Join Date
    Jan 2004
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That did the trick...
    Thank you

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Pee-H-Pee
    That did the trick...
    Thank you
    You're welcome
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

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