Looping In PHP
Last Updated on Saturday, 15 November 2008 17:03 Written by Zack Wednesday, 17 September 2008 09:32
Looping ဆိုတာကေတာ့ Programming Language တိုင္းမွာ အေရးပါတဲ့ အရာတစ္ခု ျဖစ္ပါတယ္။PHP မွာေတာ့ Looping အမ်ိဳးအစား (4) ခုဘဲ ရွိပါတယ္။
-
while
-
do while
-
for
-
foreach
- while -> Loop ထဲမွာ ပါတဲ့ Connection true ျဖစ္ေနသ၍ loop က အလုပ္လုပ္ေနပါတယ္။
syntax
while (condition)
code to be executed;
Example
<html>
<body>
<?php
$i=1;
while($i<=3)
{
echo "The number is " . $i . "<br />";
$i++;
}
?>
</body>
</html>
- do while -> ဒီ loop ကေတာ့ မွားမွား မွန္မွန္ တစ္ၾကိမ္ေတာ့ ၀င္လာျပီး အလုပ္လုပ္ပါတယ္။ျပီးမွ condition ကို စစ္တယ္ မွန္ေနတယ္ဆိုရင္ loop ကို Repeat ထပ္လုပ္ပါတယ္။
syntax
do
{
code to be executed;
}
while (condition);
Example
<html>
<body>
<?php
$i=0;
do
{
$i++;
echo "The number is " . $i . "<br />";
}while ($i<3);
?>
</body>
</html>
- for -> loop ကို ဘယ္ႏွစ္ၾကိမ္ ပတ္မယ္ဆိုတာ သိေနရင္ for ကုိ သံုးပါတယ္။
syntax
for (initialization; condition; increment)
{
code to be executed;
}
Example
<html>
<body>
<?php
for ($i=1; $i<=3; $i++)
{
echo "Welcome to JoomZack!<br />";
}
?>
</body>
</html>
- foreach -> array တစ္ခုကုိ loop ပတ္ဖို ့ၾကံဳလာတဲ ့အခါမ်ိဳးဆိုရင္ foreach ကို သံုးနိဳင္ပါတယ္။
syntax
foreach (array as value)
{
code to be executed;
}
Example
<html>
<body>
<?php
$arr=array("one", "two", "three");
foreach ($arr as $value)
{
echo "Value: " . $value . "<br />";
}
?>
</body>
</html>
တျခား PHP Post ေတြအားလုံး ကို ႏွစ္သက္ရာ ေရြးဖတ္ ခ်င္တယ္ဆိုရင္ ဒီ Link ေလးကို Click လိုက္ပါ။
| < Prev | Next > |
|---|
Login Form
Latest Post
Categories Table View
- Reader's Conner (133)
- PHP (48)
- Joomla CMS (46)
- Codeigniter (18)
- jQuery (12)
- iDhamma (11)
- Mobile Development (10)
- PHP & AJAX (4)
- Apache (3)
- For Mac (3)
- mySQL (2)
- DhammaDroid (1)
very good one.....for me to find this site is like sleepling in paradise.....thanks very much.....
to share ur knowledge....
bless u.....