Concept
How are foreach loops used to iterate over array elements in PHP?
ComputerScienceOne / Do-While Loops
"39.4. Foreach Loops\n\nFinally, PHP supports foreach loops using the keyword foreach. Some of this will be a preview of Section 42 where we discuss arrays in PHP. In short you can iterate over the elements of an array as follows.\n\n$arr = array(1.41, 2.71, 3.14);\n\nforeach($arr as $x) {\n\n//x now holds the \"current\" element in arr\n\nActually, PHP supports associative arrays, which are not the same thing as traditional arrays."
Related Ideas
- How does PHP use foreach loops to iterate over array elements?ComputerScienceOne · Foreach Loops
- How does a do-while loop differ from a while loop in PHP?ComputerScienceOne · Foreach Loops
- How are while loops structured and styled in PHP?ComputerScienceOne · While Loops
- How does a do-while loop differ from a while loop in C?ComputerScienceOne · Do-While Loops
- How do do-while loops differ from while loops in C?ComputerScienceOne · For Loops