Re: pathname

From: Date: Mon, 18 Mar 2002 06:09:18 +0000
Subject: Re: pathname
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-88892@lists.php.net to get a copy of this message
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\\"; > or > $to_path = "c:/aaa/bbb/ccc/ddd/"; > > if(!is_dir($to_path)) > { > #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 miguel

« previous php.general (#88892) next »