urldecode - Output a part of URL in php -
so, have dynamically generated pages follows following format:
http://example.com/name/first_name/last_name/john%2c+smith what php code output last part of url?
so, becomes "john, smith".
thank much.
edit:
i realized url ended / , answers given below not pick up. change should make?
http://example.com/name/first_name/last_name/john%2c+smith/ edit 2:
so, link dynamically generated following:
href="http://example.com/name/first_name/last_name/<?php echo $full_name ?>"
you can use parse_url second parameter php_url_path
$url = urldecode("http://example.com/name/first_name/last_name/john%2c+smith"); $arr = array_filter(explode('/',parse_url($url, php_url_path))); print_r(end($arr)); edited:
as per requirement dynamic url can use
$url = urldecode("http://$_server[http_host]$_server[request_uri]");
Comments
Post a Comment