parse_url() is php function which parses a URL and returns an associative array containing any of the various components of the URL that are present.
This function is not meant to validate the given URL, it only breaks it up into parts. Partial URLs are also accepted, parse_url() tries its best to parse them correctly.
$url=$_SERVER['REQUEST_URI']; $keys = parse_url($url); // parse the url $path = explode("/", $keys['path']); // splitting the path $paged=$path[2]; Example of url http://domain.com/blogs/latest-articles/123 Output Value; 123