Posted by: Sourav | February 19, 2011

Use of foreach loop in PHP


<html>
<head>
<title>
Foreachloop
</title>
</head>
<body>
<?php
$sourav=array(1,5,8,96,45,855,574,85,87,65);
foreach($sourav as $temp)
{
echo $temp.”, “;
}
foreach($sourav as $point => $temp)
{
echo “<br />”. $point. “: “. $temp.”<br />”;

}
$prices=array(“Brand New Laptop”=>2000, “1 month high tech training”=>10, “Learning PHP” =>pricelsss);
foreach($prices as $abc => $value)
{
if(is_int($value))
{
echo $abc .”: $”. $value.”<br />”;
}
else
{
echo $abc .”: “. $value.”<br />”;
}
}
?>
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: