我有2 x二維數組與數據庫返回值。php合併2個陣列
目前我在做一個foreach循環,並把返回的值到一個單獨的表,每個陣列:
如:
<table>
<tr>
<td>Auto Bavaria Midrand BMW</td>
<td>63</td>
<td>39</td>
</tr>
...
</table>
<table>
<tr>
<td>Auto Bavaria Midrand BMW</td>
<td>40</td>
<td>15</td>
...
</tr>
</table>
但我需要在此格式返回值,只有1表:
<table>
<tr>
<td>Auto Bavaria Midrand BMW</td>
//the name of the record does not need to be repeated, only the values
<td>63</td>
<td>39</td>
<td>40</td> //values from 2nd array
<td>15</td> // values from 2nd array
</tr>
...//next record set
</table>
Array
(
[0] => Array
(
[DealerName] => Auto Bavaria Midrand BMW
[dealersContacted] => 63
[DealerContact_Y] => 39
[DealerContact_N] => 15
[DealerShipId] => 21730
[DataId] => 23527
)
//extra returned records
)
Array
(
[0] => Array
(
[DealerName] => Auto Bavaria Midrand BMW
[dealersContacted] => 65
[DealerContact_Y] => 40
[DealerContact_N] => 15
[DealerShipId] => 21730
[DataId] => 23527
)
//extra returned records
)
我可以做PHP的一面,我的問題是如果有一個數組函數,可以只合並數組的所需位?我已經搜索,越來越困惑。
我認爲他給出的兩個例子應該是不同的。是的,你需要自己循環通過陣列 - 沒有神奇的內置功能。 – zaf 2013-02-27 09:21:37