On Jun 13, 2010, at 5:23 PM, Ashley Sheridan wrote:

On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:

Hello List.

I need to parse the PATH portion of URL.  I have assigned the path
portion to a variable using the following:

$thepath = parse_url($url);

Now I need to break each portion of the path down into its own
variable.  The problem is, the path can vary considerably as follows:




How do I get the either of the above url paths broken out so the
variables equal the following

$dir1 = mydirectory
$dir2 = mysubdirectory
$dir3 = anothersubdirectory
$page = mypage.php

...etc... if there were 5 more subdirectories... they would be
dynamically assigned to a variable.

  Thanks for any help.


$filename = basename($path);
$parts = explode('/', $path);
$directories = array_pop($parts);

Now you have your directories in the $directories array and the filename
in $filename.


Hi Ash,
What about the "//" in  the beginning?

Karl DeSaulniers
Design Drumm

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to