在PHP中,foreach语法[duplicate]之间存在差异

This question already has an answer here:

Is there any reason to use one foreach syntax instead of another?

foreach (array_expression as $value) {
    // statements
}

or

foreach (array_expression as $value) :
    // statements
endforeach; 
</div>

They are completely equivalent, as stated in the official manual of PHP.

See here for more info: http://php.net/manual/en/control-structures.foreach.php

Most times the foreach ... endforeach version is used in "templates". So it's easier for you to follow the logic of templates.