[thelist] Directory names

Joshua Olson joshua at waetech.com
Tue Nov 25 13:25:54 CST 2003


----- Original Message ----- 
From: "Guy Bowden" <guy at holler.co.uk>
Sent: Tuesday, November 25, 2003 1:37 PM


> If I've got a folder string in PHP like this:
>
> /546/guy/datasrc/./../email/sendtofriend/
>
> How can I turn that into :
>
> http://darkside/546/guy/email/sendtofriend/
>
> In php?

I don't do PHP but here's the programming approach I'd start with:

1.  Replace all instances of '/./' with '/'
2.  Break the string into an array using '/' as the delimiter.
3.  Loop through the array once and append '/' to the end of every element
unless the next non-empty element is '..', in which case you clear the array
element and the next non-empty element (which should be '..').
4.  Rejoin the array into a single string ensuring that the empty string is
used as the delimiter.

Good luck,

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com
706.210.0168



More information about the thelist mailing list