Reputation: 65
I encode a url having GET parameters using base64 and then decode it back to get the same url back. The string I receive is.
task_type=all&keyword=asdfsd&location=Vasant Kunj&category=17&subcategory=19&price[]=&price[]=100&price[]=300&price[]=500&price[]=above&educations[]=&educations[]=22&educations[]=29&industry[]=&industry[]=1&industry[]=7&experience=6&freshness=1
Now how can I get the original $_GET array back so that I can use it. Or any other way of getting all the parameters so that I can use them. Or any other better way to encode and decode so that original url is not visible to the user.
All help appreciated. Thanx in advance.
Upvotes: 1
Views: 95
Reputation: 1106
As you are encoding the url having GET
parameters using base64 you will not be able to get exact GET
parameters. But after decoding it you are getting the query string
back as you have mentioned, So in this case you can use parse_str()
, see doc
Example:
$queryString = "task_type=all&keyword=asdfsd&location=Vasant Kunj&category=17&subcategory=19&price[]=&price[]=100&price[]=300&price[]=500&price[]=above&educations[]=&educations[]=22&educations[]=29&industry[]=&industry[]=1&industry[]=7&experience=6&freshness=1";
parse_str($queryString, $getParamsArray);
var_dump($getParamsArray);
I guess this is what you were looking for...
Upvotes: 1