[thelist] PHP string manipulation

Anthony Baratta Anthony at Baratta.com
Thu Jun 26 18:13:33 CDT 2003


At 03:58 PM 6/26/2003, Mark Joslyn wrote:
>I am having the hardest time writing a string manipulation that will take
>the following:
>
>Directory_One/Directory_Two/FileName1.zip
>
>or
>
>Directory_One/Filename1.zip
>
>(the paths can have from 1 to 3 directories separated by "/")
>
>I need everything left of the last "/" returned as a string including the
>last "/" (essentially just removing the filename).

If you are trying to get the full path of your executing script:

$_SERVER["REQUEST_URI"]

Otherwise just explode/split on the ? and drop the last one as you concat 
them back together. There may be a function or two that does this for you.



-- 
Anthony Baratta
President
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."



More information about the thelist mailing list