創建二維數組我有這樣的結果之後,我查詢: 從MySQL查詢在PHP
我想在PHP中創建一個這樣的數組:
[
{
"software_version": "1.0",
"version_date": "10/08/2016",
"changelog": [
{
"type": "IMP",
"description": "Initial version."
}
]
},
{
"software_version": "1.0.1",
"version_date": "27/07/2017",
"changelog": [
{
"type": "ADD",
"description": "HostPanel update manager."
},
{
"type": "ADD",
"description": "Hook OnDaemonMinute."
}
]
}
]
我需要將結果與software_version
行組合。 任何幫助表示讚賞。
我的PHP代碼:
$changelog = array();
foreach ($result as $r) {
$changelog[] = array(
'software_version' => $r['software_version'],
'version_date' => $r['version_date'],
'changelog' => array(
array(
'type' => 'IMP', // help
'description' => 'Initial version.'
)
)
);
}
你爲什麼要移除你的PHP代碼? –
@ Don'tPanic我把它推回去了。 –