關於到這些問題:合併一個陣列 - 幾乎不重複值
https://stackoverflow.com/questions/37934938/marge-array-almost-uniques-value
我需要在一個陣列合併值。我有啓動值這樣的:
Array (
[row] => Array
(
[0] => Array
(
[personalnr] => 824
[brutto] => 1000
[netto] => 0
[notiz] => 0
)
[1] => Array
(
[personalnr] => 824
[brutto] => 1000
[netto] => 0
[notiz] => 1
)
[2] => Array
(
[personalnr] => 824
[brutto] => 1000
[netto] => 0
[notiz] => 3
)
)
)
問題是存在的row[0]
,row[1]
,row[2]
具有相同[personalnr]
,[brutto]
,[netto]
。 [notiz]
是每行不同。 假設在我的陣列中,我有400 [rows]
。一行重複4次,但每次只有不同的[notiz]
。我需要有隻100 [rows]
,但在每一個 - 需要被列[notiz]
4倍([notiz_1]
[notiz_2]
[notiz_3]
[notiz_4]
的[rows]
最終金額100
Array (
[row] => Array
(
[personalnr] => 824
[brutto] => 100
[netto] => 0
[notiz] => array
(
[1] = > 1
[2] = > 2
[3] = > 3
)
)
)
就像有人說我試過:
foreach ($value as $rownr => $dane) {
$nrwiersza = $rownr;
$test[$nrwiersza]['personalnr'] = $dane['personalnr'];
$test[$nrwiersza]['std'] = $dane['std'];
$test[$nrwiersza]["notiz"][] = $dane['notiz'];
}
但是數組$test
仍然有400行。如何使用鍵[personalnr]
,[brutto]
, [netto]
來確定並將每個[notiz]
放入[notiz_1]
,[notiz_2]
,[notiz_3]
,[notiz_4]
。
你的意思是'合併'嗎? – Ray
不要問同樣的問題兩次。如果你在第一個問題上沒有得到幫助,你需要澄清它,而不是再次發佈。 – Barmar