How to get the second segment in URL without slashes ? For example I have a URL`s like this
http://foobar/first/second
How to get the valu
To take your example http://domain.com/first/second
$segments = explode('/', trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));
$numSegments = count($segments);
$currentSegment = $segments[$numSegments - 1];
echo 'Current Segment: ' , $currentSegment;
Would result in Current Segment: second
You can change the numSegments -2 to get first