Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Location
    Germany/Blackforest/Furtwangen
    Posts
    1

    Question deleting the last element of a string

    Hello there!

    my question: How do I delete the last element of a string??

    i.e.: an url ends like this: .../index.php/
    and now I need to trim the last slash otherwise relatively linked images won't load anymore

    This problem with the last slash occures when I link to a file that starts a session and gets a variable. then it returns to the page it was loaded from (via $HTTP_REFERER), and at that point it adds a slash to the end...and another one if I reopen it, to change registered variable...and so on.

    So is there a possibility to cut this last slash of every time it adds it even without knowing the actual length of - in this case - the url ??

  2. #2
    Join Date
    Aug 2002
    Location
    Long Island
    Posts
    427
    PHP Code:
    $variable substr ($variable,0, (strlen($variable)-1) ) 
    would this work?
    John Trovato
    In Office Networks, LLC
    Programmer, Cisco Network Engineer, Roofer, Biochemist, and Conductor.

  3. #3
    Join Date
    Jul 2002
    Location
    Israel
    Posts
    351
    A shorter version would be

    PHP Code:
    $t 'abcd';
    $t[strlen($t)-1] = ''
    C#/C++/TCL/Python/PHP developer.
    mark at mark org il

  4. #4
    Join Date
    Aug 2002
    Location
    Long Island
    Posts
    427
    that's a good one didn't think of that...

    John
    John Trovato
    In Office Networks, LLC
    Programmer, Cisco Network Engineer, Roofer, Biochemist, and Conductor.

Posting Permissions

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