Open Open - 2 months ago 5x
PHP Question

& symbol in title breaking variable

Currently I am trying to make it so that if my title contains

in the title it will pass through the url below.


Currently I have the following code

$auth = urlencode($title2);
$auth2 = urldecode($auth);
$title2 = 'Artist - Song Name (Feat. Another Artist & Last Artist)';

You can see below that the
portion contains an
symbol, if this passes through our URL the download will look like this
Artist - Song Name (Feat. Another Artist)
leaving out the last artist in the MP3's name.

Any help is gratefully appreciated.


You need to fix the URL first so you can parse it correctly later on. Use http_build_query:, it will urlencode things correctly for you

'dl.php?' . http_build_query(array('u' => $mp3, 'n' => $auth2));