1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Trim problem

Discussion in 'PHP' started by archard, Sep 30, 2007.

  1. #1
    I told PHP to trim the word "Tabs" out of a variable using this code:

    
    trim($name, "Tabs")
    
    PHP:
    $name is always a multiple word string with the word "Tabs" at the end. But now, whenever the output starts with a capital T, the T gets trimmed as well as the word "Tabs". Any idea why?
     
    archard, Sep 30, 2007 IP
  2. clinton

    clinton Well-Known Member

    Messages:
    2,166
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    110
    #2
    trim is used to get rid of whitespace
    Just look...
    ca3.php.net/trim

    if you want to get rid of the word tab from a string, such as "3232323effef tab ffsdfsdfsfs"

    than use
    $bodytag = str_replace("tab", "replacementoftabhere", "dcadscadcctab22cdsc");
     
    clinton, Sep 30, 2007 IP
  3. archard

    archard Peon

    Messages:
    221
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't wanna replace it though, I just wanna chop it out.
     
    archard, Sep 30, 2007 IP
  4. clinton

    clinton Well-Known Member

    Messages:
    2,166
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    110
    #4
    than just do this
    $b = str_replace("tab", "", "dcadscadcctab22cdsc");
     
    clinton, Sep 30, 2007 IP
    archard likes this.
  5. archard

    archard Peon

    Messages:
    221
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Beautiful, thanks so much :)
     
    archard, Sep 30, 2007 IP
  6. clinton

    clinton Well-Known Member

    Messages:
    2,166
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    110
    #6
    np, glad I could help
     
    clinton, Sep 30, 2007 IP