space between string

Discussion in 'PHP' started by ahkip, Mar 23, 2006.

  1. #1
    if i have a string "i am very dumb", how can i convert it to "iamverydumb"
    trim() doesn't take out space between word....
     
    ahkip, Mar 23, 2006 IP
  2. Perrow

    Perrow Well-Known Member

    Messages:
    1,306
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    140
    #2
    Perrow, Mar 23, 2006 IP
  3. ahkip

    ahkip Prominent Member

    Messages:
    9,205
    Likes Received:
    647
    Best Answers:
    0
    Trophy Points:
    310
    #3
    it doesn't work for me

    this is the code

    $searchterm = $_POST['query'];
    str_replace(" ", "", $searchterm);

    i want take out the space of my vistor's query..but it doesn't work
     
    ahkip, Mar 23, 2006 IP
  4. ServerUnion

    ServerUnion Peon

    Messages:
    3,611
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You would need to set your variable to the new string value. Not sure about the syntax, might look like this...

    $searchterm == str_replace(" ", "", $searchterm);
     
    ServerUnion, Mar 23, 2006 IP
  5. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #5
    Double equal is comparison (it won't set it)... This is what you want:

    $searchterm = str_replace(" ", "", $searchterm);
    PHP:
     
    digitalpoint, Mar 23, 2006 IP