Replace spaces with +

Discussion in 'Programming' started by dawilster, Jan 2, 2009.

  1. #1
    I need help would anybody no how to replace all the spaces within a sentence or phrase and replace them with + using a code.

    thanks alot
     
    dawilster, Jan 2, 2009 IP
  2. msrmani

    msrmani Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,
    in wich language you want the code to be.
     
    msrmani, Jan 3, 2009 IP
  3. dawilster

    dawilster Active Member

    Messages:
    844
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #3
    If possible id prefer php please.

    thanks alot
     
    dawilster, Jan 3, 2009 IP
  4. manjifera

    manjifera Well-Known Member

    Messages:
    232
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    118
    #4
    <?php 
    
    $qry = "this is my test";
    $qry = trim($qry);
    $spremoved = str_replace(" ", "+",$qry);
    
    echo "$spremoved";
    
    ?>
    PHP:
     
    manjifera, Jan 3, 2009 IP