Reputation: 11
Currently using this code:
str_replace(".php","",basename($_SERVER['REQUEST_URI']))
and it outputs like this:
Rusko%20-%20Skanker.mp3&sort=1
i need it to display so: Rusko - Skanker
Upvotes: 1
Views: 345
Reputation: 13328
Say you have the following URL:
script.php?file=Rusko%20-%20Sanker.mp3&sort=1
Then, to get the result you are looking for, you would want:
echo htmlentities( urldecode( str_replace( '.mp3', '', $_GET['file'] ) ), ENT_QUOTES );
The other answers aren't quite complete because they will include the entire URL in the output. You seem to be looking for just one query string parameter.
Note: htmlentities() is VERY important in this case to protect your website and users. Printing any user submitted data on a page without properly sanitizing it first allows for code injection.
Upvotes: 1