Escaping Characters - URL Encoding.

From: Date: Tue, 24 Apr 2001 21:32:25 +0000
Subject: Escaping Characters - URL Encoding.
Groups: php.general 
Request: Send a blank email to php-general+get-50178@lists.php.net to get a copy of this message
H- I've been able to escape the 'space' character in a variable so it can be safely passed through a URL but I'm having trouble finding anything that works for escaping the '&' ampsand. Here is a snippet of code. $topic = "Aerospace & Commercial Space"; $link_value = str_replace("&", '%26', $topic); $link_value = str_replace(' ', '%20', $topic); Here's the strange part. If the "ampersand replace" is in front of the "space replace" the "space replace" gets done but the ampersand doesn't. If the "ampersand replace" is done after the "space replace" the ampersand get's replaced but the spaces do not. So for the code above the %20 was replaced but the & remained &. I split the lines up for simplicity. Is that's what's causing the problems? What am I missing here? Very confusing. Thanks for any info any one might have on this. Thoughts, Comments, Anecdotes? -Sterling

« previous php.general (#50178) next »