JSON Response to PHP Array
Dec 16, 2014
Hi everybody,
I'm trying a curl request , this is my code
The json response I got is:
the part I need is just the array "data":[[10,"Ghalia","ghalia","ghalia","ghalia@mail","6",7,8,9,"10",11,12]]
How can I convert it to php array? I tried
but it dosn't work.
I'm trying a curl request , this is my code
$voltdbserver = "http://apvv-volt-poc:8080/api/1.0/";
$proc = "SELECT2";
$a = array($username,$password);
$params = json_encode($a);
$params = urlencode($params);
$querystring = "Procedure=$proc&Parameters=$params";
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, $voltdbserver);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $querystring);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the request
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$json = json_decode($result);
//$json = json_decode($result, true);
print_r($json);
The json response I got is:
{"status":1,"appstatus":-128,"statusstring":null,"appstatusstring":null,"results":[{"status":-128,"schema":[{"name":"ID","type":5},{"name":"USER_NAME","type":9},{"name":"DISPLAY_NAME","type":9},{"name":"PASSWORD","type":9},{"name":"EMAIL","type":9},{"name":"ACTIVATION_TOKEN","type":9},{"name":"LAST_ACTIVATION_REQUEST","type":5},{"name":"LOST_PASSWORD_REQUEST","type":5},{"name":"ACTIVE","type":5},{"name":"TITLE","type":9},{"name":"SIGN_UP_STAMP","type":5},{"name":"LAST_SIGN_IN_STAMP","type":5}],"data":[[10,"Ghalia","ghalia","ghalia","ghalia@mail","6",7,8,9,"10",11,12]]}]}
the part I need is just the array "data":[[10,"Ghalia","ghalia","ghalia","ghalia@mail","6",7,8,9,"10",11,12]]
How can I convert it to php array? I tried
$user = $json['results']['data'];
print_r($user);
but it dosn't work.