Create JSON object with array array as attribute in PHP -
i'm trying create json-string looks this:
{"id":"1","name":"new group test","beschreibung":"this description","gewerbe":"1" , "members":[{"uniqueid":"100110001"},{"uniqueid":"100110002"},{"uniqueid":"100110003"}]}
right output looks this:
{"data":{"id":"1","name":"new group test","beschreibung":"this ne","gewerbe":"1"},"members":[{"uniqueid":"100110001"},{"uniqueid":"100110002"},{"uniqueid":"100110003"}]}
using following php code:
return array('data' => $data, 'members' => $members);
$data result of sql-query , $members result array of sql-query. want have members array attribute inside of data in example posted. how create string that?
$data['members'] = $members; return json_encode($data);
Comments
Post a Comment