How to use for each loop in php


For each loop is the smarter loop to use. It can be played with the keys and index values .

Mainly people use for loop more but some critical situation are faced where we are forced to use the for each loop.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>FOR EACH LOOP Examples in PHP</title>
//Lets take one simple example of array to print values with the for loop
$array = array('A','B','C','D');

foreach ($array as $value)
echo $value . "<br>";