Yesterday in the database batch import encountered the old problem (foreach+& problem)
The question can be summarized briefly as:
$arr = Array (1,2,3,4,5);
foreach ($arr as $key = & $row) {}
foreach ($arr as $key = + $row) {}
Var_dump ($arr);
Array (size=5)
0 = int 1
1 = int 2
2 = int 3
3 = int 4
4 = &int 4
foreach pointer problem, pointer big God, ask to appear!
Share to:
------Solution--------------------
$arr = Array (1,2,3,4,5);
foreach ($arr as $key = & $row) {}//This execution is complete, $arr [4] is a reference and a value of 5
foreach ($arr as $key + $row) {}//This execution means that each time the current value is assigned to $ARR[4], the value of $arr[4] at the end of the fourth loop is 4, and the fifth time is self-assigned, so it is 4.
$arr = Array (1,2,3,4,5);
foreach ($arr as $key = & $row) {}
Var_dump ($arr);
Echo $arr [4]. '
';
foreach ($arr as $key = = $row) {
Echo $arr [4]. ' _';
}
Var_dump ($arr);