Sure, why not. Just use function call in-place, like:
$array = array('some','boring','items');
$result = substr(array_reduce($array, function(&$cur, $x)
{
return $cur.='#'.ucfirst($x);
}, ''), 1);
Alternatively (if you want to avoid even string overhead when doing substr()
) - use
$result = ucfirst(array_shift($array)).array_reduce($array, function(&$cur, $x)
{
return $cur.='#'.ucfirst($x);
}, '');
-less "beautiful" - but certainly will use each element only once.