Dropping the last character of a string.

Discussion in 'PHP' started by duilen, Jul 25, 2006.

  1. #1
    I would like to turn a variable like this.
    $var = "sample1";

    Into this.
    $var = "sample";

    As far as I know str_replace wont work because the final character and the preceding characters will constantly vary.
     
    duilen, Jul 25, 2006 IP
  2. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #2
    tflight, Jul 25, 2006 IP
    duilen likes this.
  3. duilen

    duilen Active Member

    Messages:
    354
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Thanks, this is exactly what I was looking for.
     
    duilen, Jul 25, 2006 IP