Making a link from variables with spaces in (PHP)

Associate
Joined
2 Aug 2005
Posts
680
I am passing variables from a form to make a link, but one of the fields may contain spaces. Is there anyway to convert the spaces in the string when making the link into the "%20" bit?

Thanks,
 
It performs a different task.

urlencode() encodes the string ready for use in a URI/URL.

htmlentities() encodes the string ready for use as literal output to the user-agent, replacing < and > with &lt; and &gt; respectively, amongst other char's. This would also need to be urlencode()'ed because the ampersand and semi-colon are not valid URL characters. :)
 
Back
Top Bottom