Part 8
Echo!! each ($userAges). '
';
Echo!! each ($userAges). '
';
Echo!! each ($userAges). '
';
while (!! $a =each ($userAges)) {
echo $a [' key ']. ' ---'. $a [' $value ']. '
';
}
The results are as follows
Wu Qi---
Li Tinghui---
Hu Xueyan---
Zeng Guofan---
Li---
You can use each one to move past an element
//Why value cannot be displayed in a similar way?
foreach ($userAges as $key = $value)
{echo $key, '-------'. $value. '
';
The results are as follows
Wu Qi-------19
Li Tinghui-------27
Hu Xueyan-------135
Zeng Guofan-------136
Li-------137
Reply to discussion (solution)
echo $a [' key ']. ' ---'. $a [' value ']. '
';
Change it to this.
while (!! $a =each ($userAges)) { echo $a [' key ']. ' ---'. $a [' value ']. '
';}
echo $a [' key ']. ' ---'. $a [' $value ']. '
';
Value has an extra $ in front
Okay, I get it.
Thank you, guys.