$aBU= Array(Array( ' id '=' 0 ', ),Array( ' id '=' 1 ', ),Array( ' id '=' 2 ', ),Array( ' id '=' 3 ', ),);Echo"Original data
";Print_r ($aBU);Echo"
";foreach($aBU as&$bu){$bu[' Dept '] = rand ( -, 999);}//unset ($BU);Echo"Join Dept after
";Print_r ($aBU);Echo"
";Echo"Re-traverse
";foreach($aBU as$key=$bu){Print_r ($bu);Echo"
";}
Output:
Original data
Array ([0] = = Array ([id] = 0) [1] = = Array ([ID] + 1) [2] = = Array ([ID] + 2) [3] = = Array ([id] = 3))
After joining Dept
Array ([0] = = Array ([id] = 0 [Dept] = 783) [1] = = Array ([id] = 1 [Dept] = 683) [2] = = Array ([id] = 2 [Dept] = 442) [3] = = Array ([id] = 3 [Dept] + 121))
Re-traverse, the last element unexpectedly get is actually a previous element?
Array ([id] = 0 [Dept] = 783)
Array ([id] = 1 [Dept] = 683)
Array ([id] = 2 [Dept] = 442)
Array ([id] = 2 [Dept] = 442)
The above introduces the strange phenomenon of PHP, ask God to answer, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.