I have a json string i which has a object in one one there is one json array & another object i want to first the json array then convert into php array & other json object into the php variable.Please tell me how to do this. I have stdclass but i am not able to get accurate data.
Json String
{
"data": [
{
"ques_name": "no",
"ques_id": "1"
}, {
"ques_name": "yes",
"ques_id": "2"
}, {
"ques_name": "no",
"ques_id": "3"
}, {
"ques_name": "yes",
"ques_id": "4"
}, {
"ques_name": "no",
"ques_id": "5"
}, {
"ques_name": "yes",
"ques_id": "6"
}, {
"ques_name": "no",
"ques_id": "7"
}
],
"UserId": 163
}
I used following code to get the array but it gives me array of size 14 where as size should be 7
$params=$_GET['params'];
$arr=array();
$decode=json_decode($params);
$arr=$decode->data;
print_r($arr);
print_rgive you?