How to find a directory in url?

Discussion in 'PHP' started by baris22, Aug 31, 2009.

  1. #1
    baris22, Aug 31, 2009 IP
  2. almondj

    almondj Peon

    Messages:
    768
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Do you mean you need to get a file from the others directory?

    Just go back to levels.

    http://localhost/index/others (back two)/back one/current level

    
    include('../FILE OR DIRECTORY + FILE');
    
    PHP:
     
    almondj, Aug 31, 2009 IP
  3. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    i did like this but i do not know if it is the right way

    
    
    $serverurl = $_SERVER['REQUEST_URI'];
    $parsed_url = parse_url($serverurl);
    $exploded = explode('/', $parsed_url['path']);
    
    $second = $exploded[2];
    echo $second;
    
    
    PHP:
     
    baris22, Aug 31, 2009 IP
  4. HivelocityDD

    HivelocityDD Peon

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    otherwise you can make use of preg_match() function of php
     
    HivelocityDD, Sep 1, 2009 IP
  5. bugcoder

    bugcoder Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    try this code

    $sCurDir = @explode("\\", getcwd( ));
    $sCurDir = $sCurDir[(count($sCurDir) - 1)];
     
    bugcoder, Sep 1, 2009 IP