Ok, I'm officially embarrassed. I read about this MVC intro in php, and I see this code, and I added some elements to the array above to see if it really works.
<?php $members = array('apple', 'oranges', 'banana'); ?> <html> <h1>Members of community.com:</h1> <ul> <?php foreach ($members as $i => $member) : ?> <li>Member #<?php echo $i + 1; ?>: <?php echo $member; ?></li> <?php endforeach; ?> </ul> </html>
I noticed there a: in the foreach statement line. Where does this come from? More importantly, what is it? This: the symbol means "okay, we will continue this statement in the next line"?
But also, this is a cool trick that I recognized. Fewer html tags inside my php echo, I think.
let me know what you think, thanks!
arrays php foreach
Matt
source share