I have a url that gets encoded when serialized with jquery and comes out like this:
index.php?city%5B%5D=METROPLOIS&city%5B%5D=GOTHAM
Supposed to be index.php?city[]=METROPLOIS&city[]=GOTHAM
On the other end, I’m using joomla to pull down a bunch of variables out of the url
$city = JRequest::getVar('city');
Now, another user was nice enough to point me to this code in PHP which would get the city variables and then implode them into
$cities = $_GET['city'];
$str = "CITY='".implode("' OR CITY='",$city)."'";
Where $cities = $_GET['city']; is equivalent to $city = JRequest::getVar('city');
So, I’m running into a challenge that I don’t know how to address. How to decode the URL in Joomla so that it will recognize city%5B%5D as city[] or city.
I’ve seen this: http://php.net/manual/en/function.urldecode.php, but that pulls down the URL and puts it into a string. How would I then tell Joomla to pull variables form that string instead of the URL ?
Use urldecode to decode the url
DEMO
http://php.net/manual/en/function.parse-url.php
http://php.net/manual/en/function.parse-str.php