I have a URL like http://localhost/m/2016/05/05/sebut-gubernur
.
If link is clicked, I want get sebut-gubernur
.
I have a URL like http://localhost/m/2016/05/05/sebut-gubernur
.
If link is clicked, I want get sebut-gubernur
.
The $_SERVER
variable helps your. and also explode function.
$part = explode("/", urldecode($_SERVER['REQUEST_URI']));
echo $part[(count($part) - 1)]; //sebut-gubernur
Note: You also need
.htaccess
code for this kind of url.
OR
If you have the link as a string and want to get sebut-gubernur
then try:
$link = 'http://localhost/m/2016/05/05/sebut-gubernur';
$part = explode("/", urldecode($link));
echo $part[(count($part) - 1)]; //sebut-gubernur