I thought I would be able to use the easy http_build_query to encode some GET parameters from an array, but apparently the enc_type seems to have been added in PHP 5.4. Unfortunately I’m on PHP 5.3.10.
Problem is that I need the parameters encoded with spaces being %20 and not +. Any good nice quick solutions of encoding the parameters correctly without using http_build_query?
Since the URL is encoded when
http_build_queryreturns, so that+are always and only spaces, you can just chain it withstr_replace:If you don’t want to encode the
~as well: