Amir Rachman Amir Rachman - 5 months ago 6
JSON Question

Handling Space url in json

I've url like this for the json format. 2000:34:00&GPSEND=13-05-2016 2014:34:00

when i passed to url in the browser there is an extra '%' string like below

how to handle that % ?, how to convert to UTF-8 my script can read the json format, just like i paste on the browser.

public function getMapLine() {

$superspring_url=" 2000:34:00&GPSEND=13-05-2016 2014:34:00";

$curl = curl_init($superspring_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
//execute the session
$curl_response = curl_exec($curl);
//finish off the session

$decoded = json_decode($curl_response,TRUE);


i use that above script to dump but this one is the below result because of the '%' string.

string(14) "Query failed! "

but when i try to use that % on my php script it shown the url.


Add the below code above $curl = curl_init($superspring_url); :

$superspring_url = str_replace (' ', '%20', $superspring_url);