Reputation: 1477
One of the things I've really trouble is with regex, I just dont understand it :-(
So, I just need to check if one url has or not folder names after .com
or .net
or .whatever
and if it has, isolate them in a variable, example
www.mysite.com
(perfect) and www.mysite.com/folder
or http://mysubdomain.mysite.com/folder/folder
the goal is to be able of isolate the folder names in a variable to be used as a path for upload
Upvotes: 1
Views: 474
Reputation: 145472
You can use parse_url()
more easily for that.
print_r(parse_url("http://mysubdomain.mysite.com/folder/folder"));
Gives you:
Array
(
[scheme] => http
[host] => mysubdomain.mysite.com
[path] => /folder/folder
)
And then just take the path
out of that.
Upvotes: 4
Reputation: 33908
Use PHPs parse_url()
http://php.net/manual/en/function.parse-url.php
Upvotes: 5