Currently I have this url with paramanters. The $filter is in string format and rawurlencoded. Is it possible to use an array instead of string for the $filter? Like array('groups'=>array('11','22','33'))
?
Here’s a sample code that is working.
$endpoint = 'https://api.com/queries';
$filter = "groups:['11', '22', '33']";
$url = $endpoint . '?filter=' . rawurlencode($filter);
It produces this url:
https://api.com/queries?filter=groups%3A%5B%2711%27%2C%20%2722%27%2C%20%2733%27%5D
2
Answers
What is your expected result? Show us..please
Try to use
urlencode()
function just after to usejson_encode()
function like this :After this you can decode the URL-encoded JSON string and convert it back to an array like this :.