Changes

Jump to: navigation, search

PHP Arrays

No change in size, 18:28, 1 June 2007
Looping through PHP Array Elements
It is often necessary to loop through each element of an array to either read or change the values contained therein. There are a number of ways that this can be done.
One such mechanism is to use the ''foreach'' loop. The foreach loop works much like a for or while loop and allows you to iterate through each array element. there There are two ways to use foreach. The first assigns the value of the current element to a specified variable which can then be acessed in the body of the loop. The syntax for this is:
foreach ($arrayName as $variable)

Navigation menu