我有以下輸出二維數組改變二維數組的索引
Array
(
[0] => Array
(
[customer_id] => 7
[language_id] => 1
[variableitem_id] => 13
[name] => QUESTION_HEADLINE
[value] => Bitte geben Sie Ihren Downloadkey ein:
)
[1] => Array
(
[customer_id] => 7
[language_id] => 1
[variableitem_id] => 15
[name] => QUESTION_BUTTON
[value] => Start!
)
)
我想陣列的輸出轉換爲這樣的事情
Array
(
[QUESTION_HEADLINE] => Array
(
[value] => Bitte geben Sie Ihren Downloadkey ein:
)
[QUESTION_BUTTON] => Array
(
[value] => Start!
)
)
我使用這段代碼爲什麼它不給我合適的索引名稱
$final = array();
foreach($data['variables_data'] as $vals){
$final[$vals['name']]['value'] = $vals['value'];
echo '<pre>';
print_r($final[$vals['name']]['value']);
echo '</pre>';
}
它很簡單,你只需要一個循環 – safarov 2012-04-02 14:56:19