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 the foreach syntax iterate over an array in PHP?ComputerScienceOne · Normalizing a Number
- How can you iterate through an array using foreach?ComputerScienceOne · Adding Elements
- How can you iterate over indexed and associative arrays in PHP?ComputerScienceOne · Iteration
- How do you create and index arrays in PHP?ComputerScienceOne · Creating Arrays
- How are for loops structured in PHP?ComputerScienceOne · For Loops
- How can you iterate over Java arrays?ComputerScienceOne · Basic Usage
- What are enhanced for loops in Java?ComputerScienceOne · Enhanced For Loops