http://www.example.com/hu/link
Using PHP how can I only keep the hu
? Please note that the link
is only one variable, it may be anything
http://www.example.com/hu/link
Using PHP how can I only keep the hu
? Please note that the link
is only one variable, it may be anything
One solution is this:
$split = explode("/", $_SERVER["REQUEST_URI"]);
echo $split[1];
$url = "http://www.example.com/hu/link";
$split_url = explode('/', $url);
echo $split_url[3];
Output:
hu
You can use a regular expression preg_match like this:
$url = 'http://www.example.com/hu/link';
preg_match('/.*www.*\/(.*)\//i',$url, $matches);
print_r($matches[1]);