Syntax with "endforeach" used mostly in complex templates where easier to find "endforeach" than "}":
<?php
foreach ($arr as $key => $value):
echo 'Key: '.$key.' Value: '.$value."<br />\n";
endforeach;
?> |
<?php
foreach ($arr as $key => $value):
echo 'Key: '.$key.' Value: '.$value."<br />\n";
endforeach;
?>
Classic syntax:
<?php
foreach ($arr as $key => $value){
echo 'Key: '.$key.' Value: '.$value."<br />\n";
}
?> |
<?php
foreach ($arr as $key => $value){
echo 'Key: '.$key.' Value: '.$value."<br />\n";
}
?>