У меня есть массив, как показано ниже
Array
(
[0] => stdClass Object
(
[id] => 67
[contact_id] =>
[status] => Complete
[is_test_data] => 0
[datesubmitted] => 2018-05-24 03:56:35
[SessionID] => 1527148487_5b066fc7bdcd75.00827785
[Language] => English
[datestarted] => 2018-05-24 03:54:47
[iLinkID] => 6528804
[sResponseComment] =>
[responseID] => 67
[[question(9)]] => Yes
[[question(24)]] => Satisfied
[[question(25)]] =>
[[question(26)]] =>
[[question(27)]] =>
[[question(28)]] =>
[[question(29)]] =>
[[question(31)]] => Likely
[[question(32)]] =>
[[question(33)]] => 26-35
[[question(35)]] => Male
[[question(36)]] =>
[[question(37)]] => No
)
)
Который я пытаюсь получить, как показано ниже
Array
(
[0] => Array
(
[id] => 67
[submitted] => 2018-05-24 03:56:35,
[question_9]=>yes
)
)
Я просто попробовал array_map
$derived=array_map(function ($a){ return array('id'=>$a->id,
'submitted'=>$a->datesubmitted,
'question_9'=>$a->[question(9)]//this is not a right way, what is best practice
);
}, $survey_array);
error :Parse error: syntax error, unexpected '[', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in