Array $tongji1, $tongji 2, $tongji 3, $tongji 4, $tongji 5, $tongji 6, $tongji 7, $tongji 8, respectively
Structure similar to
$tongji 1=array
(
[KC1] = = Array
(
[Zong] =>2
[RS] =>3
)
[Kc2] = = Array
(
[Zong] =>4
[RS] =>5
)
)
$tongji 2=array
(
[KC1] = = Array
(
[Zong] =>4
[RS] =>5
)
[KC3] = = Array
(
[Zong] =>1
[RS] =>2
)
)
......
The simplicity contained in the array now wants to combine several arrays with the same kc*, using the following code
$tongjiz = $tongji 1;
for ($x =2; $x <9; $x + +) {
$z = "Tongji". $x;
foreach ($ $z as $k = + $v) {
if (Array_key_exists ($k, $tongjiz)) {
$tongjiz [$k][zong]= $tongjiz [$k][zong]+$ $z [$k][zong];
}else{
$tongjiz [$k]=$ $z [$k];
}
}
}
Now to $tongjiz[$k][zong]= $tongjiz [$k][zong]+$ $z [$k][zong];
Found to be because $ $z [$k][zong] This problem is not an array
But I can output the array when I Print_r ($ $z) alone
Start with Print_r ($ $z [$k])
Excuse me, this is why ah, thank you.
Reply to discussion (solution)
$ $z [$k] [' Zong ']
To write
${$z}[$k] [' Zong ']
$ $z [$k] [' Zong ']
To write
${$z}[$k] [' Zong ']
That's it, thank you so much.
has been resolved