Oh, I'm dizzy again, help me.
$_post[' Flags ']=array (1,2,3,4, ' A ', ' B ', ' C ');
foreach (($_post[' flags ')) as $v) {
echo $_html = $v. ', ';
}
Echo $_html;
?>
A little puzzled.
The first one: echo $_html = $v. ', '; Get the value is 1,2,3,4,a,b,c, I understand
The second one: Echo $_html; Get the value should be the same as above, why you get C,
------Solution--------------------
Foreach
You assign a value in the loop, so every time this value is refreshed and finally gets the last value of the loop, so that's C.
------Solution--------------------
Explore
Foreach
You assign a value in the loop, so every time this value is refreshed and finally gets the last value of the loop, so that's C.
------Solution--------------------
$v. ', ';
Together, they are assigned to HTML, not HTML $v. ', '
------Solution--------------------
To get the results you want.
Change
PHP Code
foreach (($_post[' flags ')) as $v) {echo $v. ', '; $_html. = $v. ', ';}