Jump to content

whats the difference between these two loops ??


lostnucleus

Recommended Posts

Given $data = array('net','cat','wet','bat')  then wats the difference between following these two loops ??

 

  <?php  foreach($data as $moo)?>
  <?php { ?>
       <?php echo $moo;?>
  <?php } ?>

 

and

 

  
<?php foreach($data as $moo)
{
   echo $moo;
}
?>

 

Thanks in Advance as usual  8)

<?php  foreach($data as $moo)?>

 

Is the same as

 

<?php  foreach($data as $moo); ?>

 

Therefor $moo contains the last element (as the loops assigns the last element to $moo) and you echo out the last element. This is not a bug I just didn't see it right.

<?php  foreach($data as $moo)?>

 

Is the same as

 

<?php  foreach($data as $moo); ?>

 

Therefor $moo contains the last element (as the loops assigns the last element to $moo) and you echo out the last element. This is not a bug I just didn't see it right.

 

nw even i can see it right thx 2  u :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.