What am I doing wrong with the foreach()?

Quote from the book:
[Then chew about the fact that there is a brief design for numeric arrays]...to iterate through a numeric array of missing. [Yes, Yes. Nothing more. Further is shown a numerical array and a foreach without $value]
<- There is a typo that viswajeet question

Why the code does not work without the $value? That is all as in the book: a numeric array with and without the foreach $value. And why the $value be mandatory?
 $array = array("asdasd", "YYY");
 foreach($array as $dish =--> $value){
 $array[$dish] = $array[$dish] . $array[$dish];
 print $array[$dish];
June 10th 19 at 15:37
1 answer
June 10th 19 at 15:39
Because this design $dish => $value assumes an associative array, and you index.
You need to sort out it as already written above:
foreach($array as &$item) {
 $item .= $item;

or even use for:
for ($i = 0;$i < count($array), $i++){
 $array[$i] .= $array[$i];

Find more questions by tags PHP