I have a url that looks like that
http://example.com/index.php?id=111&title=word1 word2 word3
I need to encode the spaces before requesting the url with curl.
But how to urlencode the right parts of the url.
urlencode and rawurlencode encode the slashes of https the question mark etc.
You can use parse_url() to split the URL into its respective pieces. Use
urlencode()on thequeryelement from the array thatparse_urlreturns, then put it back together using http_build_url.NOTE:
http_build_urlrequires PECL pecl_http >= 0.21.0