How can I take a URL path like this and break it up to
- the params, which in this case would be
param1=1andparam2=2 - the end script, like
levelE - the middle folders in my script
levelA, levelB, levelC, levelD
.
http://test.com/ levelA/ levelB/ levelC/ levelD/ levelE ? param1=1 & param2=2
Another example would be this, where the folder depth is different, and the number of parameters is different:
http://test.com/ levelA/ levelB/ levelC/ levelD ? param1=1 & param2=2 & param3=3
Use
parse_url()to split the URL, andparse_str()to split the query string into its components.The
levelA/levelB/levelCpart is best split usingexplode().