Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,738

    Finding the name of the current sub-directory

    Hey I have a script that installs a .htaccess file for the client but I have a small problem.

    How can I determine the name of a subdirectory a script resides in?

    For example script is at: http://mysite.com/resources/myscript.php

    How could I find that it's at resources/ ?

    Thank you very much.
    <<< Please see Forum Guidelines for signature setup. >>>

  2. #2
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,738
    Got it to work finally.

    Heres the code - if you see any errors tell me
    PHP Code:
    <?php
    function sub_dir_func($url$base){
        
    $sub_dir explode("/",$url);
        
    $return_url '';
        
    $counted count($sub_dir);
        if(
    $counted 2) {
            for(
    $i=1;$i $counted-1$i++){
                
    $return_url .= $sub_dir[$i].'/';
            }
            
    $return_url $base.'/'.$return_url;
        }
        else 
    $return_url $base.$counted;
        
        return 
    $return_url;
    }
    ?>
    <<< Please see Forum Guidelines for signature setup. >>>

Posting Permissions

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