- sprintf: documentation ( source)
<?php
//Source: https://bugs.php.net/bug.php?id=54367
class MyObjet implements ArrayAccess
{
// All the stuff for ArrayAccess
public function offsetGet ($offset)
{
return function ($var) use ($offset) { // here is the problem
return sprintf('<%s>%s</%$1s>', $offset, $var);
};
}
}
$a = new MyObjet();
echo $a['p']('foo');