& Amp; lt ;? Php $ arrarray (& #039; a & #039; & amp; gt; & #039; aa & #039;, & #039; B & #039; & amp; gt; & #039; bb & #039;, & #039; c & #039; & amp; gt; & #039; cc & #039 ;); foreach ($ arras $ key & amp; gt; $ v) {$ $ key $ v;} echo $ a; aa $ key and the variable should be aa; but output a only has content $ Arr = array ('A' => 'A', 'B' => 'bb', 'c' => 'cc ');
Foreach ($ arr as $ key => $ v ){
$ Key = $ v;
}
Echo $ a; // aa
$ Key and the variable should be aa, but output a only has content
Reply content:
$ Arr = array ('A' => 'A', 'B' => 'bb', 'c' => 'cc ');
Foreach ($ arr as $ key => $ v ){
$ Key = $ v;
}
Echo $ a; // aa
$ Key and the variable should be aa, but output a only has content
You are dazzled...
$key ===> 'a'$$key ===> $a
$ V is 'A'
$ This is the usage of variable, $ key is equivalent to $ a ($ key = 'A'), and then $ v is equal to 'A ', then, $ a = 'aa'; is equivalent to defining a variable named 'A' for $ a in the loop body '...
$ V = 'A', $ key = 'A', $ key = $ a, $ key = $ v so $ a = 'A '.