foreach ($array as $item) {
if (each($array) === false) {
# last iteration
}
}
You iterate over the original array using
each, but ignore the output if it's not boolean false. foreach derps around on the copy of the array, and when the original array finishes being iterated, each returns false! So you basically iterate over the array while you iterate over the array.In Template::Toolkit you can also test for the last iteration of a loop with
loop.last, which is why that is also a good templating language.In conclusion, PHP is a templating language.
Oh right, leave a comment with your own one for whatever bozo templating language you like :)
