Re: String Parse Help for novice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jun 13, 2010, at 5:13 PM, 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:

/mydirectory/mysubdirectory/anothersubdirectory/mypage.php

vs.

/mydirectory/mypage.php

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.

 --Rick



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


Hi Rick,

Just a thought, but cant you do something to separate them according to the "/" (forward slash)?
maybe preg_replace or something. Sorry not much more help.


Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux