I want to get filename without any $_GET variable values from a URL in php?
$_GET
My URL is http://learner.com/learningphp.php?lid=1348
http://learner.com/learningphp.php?lid=1348
I
Try the following code:
For PHP 5.4.0 and above:
$filename = basename(parse_url('http://learner.com/learningphp.php?lid=1348')['path']);
For PHP Version < 5.4.0
$parsed = parse_url('http://learner.com/learningphp.php?lid=1348'); $filename = basename($parsed['path']);