Hi there, I couldn't find a solution to this small problem so posting it here.
I have some hardcoded values I want to send back to the browser. When I have this code:
...
$cr1 = '{"date_added":"8/3","type":"1","contact":"John Smith"}';
$cr2 = '{"date_added":"8/7","type":"2","contact":"Jane Smith"}';
$company_reqs[0] = json_decode($cr1,1);
$company_reqs[1] = json_decode($cr2,1);
$company_data['reqs'] = $company_reqs;
...
$results['company'] = $company_data;
echo json_encode($results);
the requirements for company get passed correctly doing an Ajax call. But if I want to have requirements for multiple companies, like these:
...
$cr1 = '{"date_added":"8/3","type":"1","contact":"John Smith"}';
$cr2 = '{"date_added":"8/7","type":"2","contact":"Jane Smith"}';
$company_reqs['100'][0] = json_decode($cr1,1);
$company_reqs['100'][1] = json_decode($cr2,1);
$company_data['reqs'] = $company_reqs[$company_id];
...
$results['company'] = $company_data;
echo json_encode($results);
the requirements are null. I tried sending it directly to the browser, and the requirements are not null to my surprise! I get this:
{"company":{"company_id":"109","reqs":[{"date_added":"8\/3","type":"1","contact":"John Smith"},{"date_added":"8\/7","type":"2","contact":"Jane Smith"}]},"contact":{...}}
Thanks in advance!