On Mon, 18 Mar 2002, jtjohnston wrote:
> I need a function to traverse a pathname
> to check if the path exists, if not start from scratch
> and create (MkDir) the path.
> Let's say:
> $to_path = "c:\\aaa\\bbb\\ccc\\ddd\\";
> $to_path = "c:/aaa/bbb/ccc/ddd/";
> #I need to explode by both \\ AND / to find out
> mkdir($to_path, 0777);
> How do I parse it and MkDir the path?
1. Change all \\ to /
2. Explode the string on /
3. Loop $i from 1 to number of parts
3a. Implode $i elements from the exploded array on / to form a subpath
3b. Does that directory exist?
3c. If not, mk it
3d. Increment $i and go back to 3a
4. Presto, you're done
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php