I have the next URL: http://domen.com/aaa/bbb/ccc
.
How can I get the string after http://domen.com/
?
Thanks a lot.
I have the next URL: http://domen.com/aaa/bbb/ccc
.
How can I get the string after http://domen.com/
?
Thanks a lot.
You can use PHP's split.
Your code will be something like:
$s = "http://domen.com/aaa/bbb/ccc";
$vals = split("http://domen.com/", $s);
// $v will contain aaa/bbb/ccc
$v = $vals[1];
$sub = substr($string, 0, 10);
But if you actually want to parse the URL (that is, you want it to work with all URLs), use parse_url. For "http://domen.com/aaa/bbb/ccc", it would give you an array like this:
Array
(
[scheme] => http
[host] => domen.com
[user] =>
[pass] =>
[path] => /aaa/bbb/ccc
[query] =>
[fragment] =>
)
You could then compile this into the original url (to get http://domen.com/):
$output = $url['scheme'] . "://" . $url['host'] . $url['path'];
assuming $url contains the parse_url results.
http://php.net/manual/en/function.parse-url.php Might be the way to go.
If you simply want the string and the "http://domen.com/" part is fixed:
$url = 'http://domen.com/aaa/bbb/ccc';
$str = str_replace('http://domen.com/','',$url);