Is this code 100% ok?!

Discussion in 'PHP' started by redhits, Sep 1, 2009.

  1. #1
    $this_url=trim($buffer[4]); $x=strlen($this_url)-1;
    if($this_url[0]=='/'){$this_url[0]='';}
    if($this_url[$x]=='/'){$this_url[$x]='';}

    welkk is working on my windows machine, but will it work on any other machine?!
     
    redhits, Sep 1, 2009 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    This would probably be better, assuming you're trying to remove directory separators from the end and beginning of a path.

    $this_url = trim($buffer[4], " \t\n\r\0\x0B\xA0\\/");
    PHP:
     
    joebert, Sep 1, 2009 IP