For each in Php


For each loop is used only for array

E.g


//You are splitting the word

$a="SachinTendulkar";
$b=str_split($a);

// To print each letter in that array you can use a For each loop

foreach($b as $c)
{
echo $c;
echo "\n";
}

?>

This is the basic example of For Each Loop in Php

This entry was posted on Saturday, August 29th, 2009 at 11:53 pm and is filed under Php-Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Post a Comment