http://codingvilla.com/traverse-list-using-each-function-php-single-article-658.aspx Each() function in php: Each () is a built-in function in php. This function returns the recent value and also moves the index pointer one step forward. Syntax: each (array) Array: whose value is displayed and pointer move forward. List () function in php: List () function is just like an assignment operator that was used to assign a value just like this list () is used to assign a value. But the difference between assignment operator and list () is that list () can assigns value more to than one variable but assignment operator can assign value to only one variable. Syntax: List(var1, var2...) Var1 is required but variable2 is optional. Traverse list using each () function in PHP: To assign and show the current value of an array we use each () and list () function. In the given code we have an array name spices. We have assigned value to the array through list () function and have shown values that was assigned through each () function. We have traversed the list using each function. Code: <?php $spices = array("A", "B", "C", "D", "E"); reset ($spices); while ( list ($key, $val) = each ($spices) ) : print "$val <br>"; endwhile; ?> Above is a simple code to traverse list using each () function in php. This simple article tells that how we can traverse list using each () function in php.
Traverse list using each () function in php.