savagenoob Posted December 9, 2011 Share Posted December 9, 2011 I have an address in a variable, I pass this address to a google maps page/function that geocodes it and returns the street view. Heres an example of a link: <a href="mapget.php?address=<?php echo urlencode(strip_tags($comaddress));?>" name="mapit">Map It</a> The address' come from either a curl or dom request so I have been trying to strip and trim them as much as possible but the urls come out looking like... www.mysite.com/mapget.php?address=7855+N+SOMESTREET+AVE+SOMECITY++++++++++++++++++++++%2C+CA+11111 My maps only seem to be getting the street... I am using urldecode($address) on the receiving page and when I echo $address on the receiving page it looks completely correct. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/252847-urlencode-help/ Share on other sites More sharing options...
xyph Posted December 9, 2011 Share Posted December 9, 2011 You need to remove excess whitespace. Since HTML shouldn't output the extra whitespace, it appears fine Use preg_replace and use an expression like '/\s{2,}/' to replace any instances of 2 or more white spaces with a single space. Quote Link to comment https://forums.phpfreaks.com/topic/252847-urlencode-help/#findComment-1296341 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.