Pick Last element from the url in php

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.

$keys = parse_url($url); // parse the url
$path = explode("/", $keys['path']); // splitting the path
Example of url
Output Value;