Use each() with a while loop in PHP
Description
The following code shows how to use each() with a while loop.
Example
<!DOCTYPE html>/*w w w .j a v a 2 s. com*/
<html>
<body>
<dl>
<?php
$myBook = array( "title" => "PHP",
"author" => "java2s.com",
"pubYear" => 2014 );
while ( $element = each( $myBook ) ) {
echo "<dt>$element[0]</dt>";
echo "<dd>$element[1]</dd>";
}
?>
</dl>
</body>
</html>
The code above generates the following result.