encountered a weird problem while writing code
$stack = "";
$collections = [1,2,3,4,5,6];
foreach($collections as $key => $collection) {
$stack[$key] = $collection . "_" . $key;
}
var_dump($stack);
the same code, the output in php7 is 1234567
but in php5 it is
array(7) {
[0]=>
string(3) "1_0"
[1]=>
string(3) "2_1"
[2]=>
string(3) "3_2"
[3]=>
string(3) "4_3"
[4]=>
string(3) "5_4"
[5]=>
string(3) "6_5"
[6]=>
string(3) "7_6"
}
Why is this
the sample on the Internet does not explain why, ask for the boss"s answer, thank you