- 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";
}
}
function allAbove(Traversable $in)
{
foreach($in as $word) {
yield array('upper' => strtoupper($word), 'rev' => strrev($word), 'combined' => strrev(strtoupper($word)));
}
}
each_println(reverse(uppercase(new ArrayIterator(["foo", "bar", "baz"]))));
foreach(allAbove(new ArrayIterator(["foo", "bar", "baz"])) as $item) {
each_println(new ArrayIterator($item));
}