$result = array();
foreach ($keywords['data'] as $key => $one) {
$result['data']['main'][$key] = $one;
$result['data']['secondary'][$key] = $one;
}
$result = ['data' => [
'main' => $keywords['data'],
'secondary' => $keywords['data'],
]];
https://ideone.com/fi0l5o