Page 1 of 1

how to parse this json

Posted: Mon Jan 20, 2014 2:07 pm
by sallaudin

Code: Select all

$json = '{"Data":{"Date":"08:09 20-01-2014","SchoolID":"923214157777","Type":"1","Nic":["3520135201001","3520135201002","3520135201003"]}}';
$main_array=json_decode($json);
foreach($main_array->Data as $key=>$value ) {
 if(is_array($value)) {
        echo "$Date:\n";
    } else {
        echo "$key => $value\n";
    }
i am using this approach but i want to get the values on the behalf of keys and get all the nic in one go

Re: how to parse this json

Posted: Mon Jan 20, 2014 4:00 pm
by Christopher
$main_array->Data->Nic