0

I'm building an application using a significant amount of custom PHP running on top of Wordpress in which I pass arrays over via GET query parameters. The query strings I generate look like this:

http://mydomain.com/locations.php?filters&f[184]=1&f[197]=1&f[235]=1&f[912]=1&setPage=1

Unfortunately, wordpress strips the [ and ] from the query string leaving this:

/locations.php?filters&f184=1&f197=1&f235=1&f912=1&setPage=1

Does anyone know how to prevent this from happening?

Thanks in advance, Dave

2 Answers 2

2

In php, http://php.net/manual/en/function.urlencode.php.

In javascript, http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I've always used urlencode on the values of query string parameters but never thought to use it on the parameter name itself. Worked like a charm!
0

Use http_build_query( $args ) to build your URL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.