Iterations

3 views
Skip to first unread message

Mohammed Jebrini

unread,
Sep 27, 2010, 2:47:23 PM9/27/10
to <?PHPalClub
<?php


// if
if($x === 10)
{
// do smthing
}
else
{
// do else
}

if($x === 10)
echo " if ";
else
echo "else ";


if($x != 10 ):


else:




endif ;



$y = ($x === 10 ) ? 10 : 90 ;



// for

for($x=0 ; $x <= 19 ; $x++ )
{

echo $x ;
}


// foreach
$arr = array('x','y','z');

foreach($arr as $row)
{
echo $row ;
}


$arr = array(
'x'=> 10 ,
'y'=>80,
'z'=>100
);

foreach($arr as $key => $value)
{
echo $key." = ".$value;

}


// while

// do while

while($x == 1 )
{


if ( $y == -1 )
continue ;


// do smthing here

}

do {

echo "True ";

} while($_1 == 1);



// switch

switch($x)
{
case 1 :
case 2 :

// do somthing here
break ;

default :
break;

}

Reply all
Reply to author
Forward
0 new messages