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 3 of 3
  1. #1
    nst
    nst is offline
    New Coder
    Join Date
    Jul 2005
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    trim a string from every space

    Is there a way to get rid of blank spaces in a variable?

    e.g. $str = "foo f o o" should be "foofoo"

    trim makes is good for the start and the end of the string, but what about the rest?

    Thanks.

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    could you just do

    $my_string = "foo f o o";
    $str = str_replace(" ","",$my_string);

  • #3
    nst
    nst is offline
    New Coder
    Join Date
    Jul 2005
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    True!

    So simple and great.

    Thanks.


  •  

    Posting Permissions

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