关于到这些问题:合并一个阵列 - 几乎不重复值
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