[ create a new paste ] login | about

Link: http://codepad.org/DTCDMfei    [ raw code | output | fork ]

martin@mustbebuilt.co.uk - PHP, pasted on May 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
function getDirectory($full, $noDir=0){
    $pos1 = strripos($full, "/");
    $path = substr($full, $pos1);
    if($noDir == 0){
        $path = str_replace("/", "", $path);
    }
    for($i=0;$i<$noDir;$i++){
       $slash1 = substr($full, 0, $pos1);
       $pos2 = strripos($slash1, "/");
       $slash2 = substr($slash1, $pos2);
       $path = $slash2 . $path;
       $full = $slash1;
       $pos1 = strripos($full, "/");
    }
    return $path;
}
$origPath = "http://www.mustbebuilt.co.uk/wp-content/themes/basic/images/search.png";
$newPath = getDirectory($origPath);
echo $newPath;
?>


Output:
1
search.png


Create a new paste based on this one


Comments: