- strtoupper: documentation ( source)
- strrev: documentation ( source)
<?php
function uppercase(Traversable $in)
{
foreach ($in as $word) {
yield strtoupper($word);
}
}
function reverse(Traversable $in)
{
foreach ($in as $word) {
yield strrev($word);
}
}
function each_println(Traversable $in)
{
foreach ($in as $line) {
echo "$line\n";
}
}
$words = new ArrayIterator(["foo", "bar", "baz"]);
each_println(reverse(uppercase($words)));