$answers['answers'] = [];
foreach ($query as $item) {
$answers['answers'][] = ['id' => $item['qid'], 'aid' => $item['aid']];
}
array_map(function (Value $value) {
return [
'label' => $value->characteristic->name,
'value' => $value->value,
];
}, $product->values);
$answers['answers'] = array_map(function ($item) {
return [
'id' => $item['qid'],
'aid' => $item['aid'],
];
}, $query);
$myFunc = function($carry, $item) {
$carry[] = ['id' => $item['qid'], 'aid' => $item['aid']];
return $carry;
}
$answers['answers'] = array_reduce($query, $myFunc, []);