Passing arrays via query string in wordpress
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://myd开发者_JAVA百科omain.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
In php, http://php.net/manual/en/function.urlencode.php.
In javascript, http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp
Use http_build_query( $args )
to build your URL.
精彩评论