PHP
forEach-Loop
Login To Post Your Comment
1 comments
Manfred Lim
4 years agoHi Colleen,
This is because your "key" is all "Honda", hence when the foreach loops the first time, it is "Honda = exMotion", 2nd time it detects "Honda" as the key again, and it will overwrite/replace the previous data cause it has the same "key". Hence, you will ultimately only see the last unique "key" value, which in this case is "Honda = NC750".
I hope this makes sense. Do let me know if you don't understand, I will try to clarify further.
//When i print out the code below, it give ms only 1 result . Not sure why.//