I have a class with a callback. I pass the string to the class and the callback is called with that string as a callback function. This is a bit like this:
$obj->runafter( 'do_this' );
function do_this( $args ) {
echo 'done';
}
What I want to do is run this inside the loop and so that the function is not written several times. I want to add a variable to the function name. I want to do something like this:
for( $i=0;$i<=3;$i++ ) :
$obj->runafter( 'do_this_' . $i );
function do_this_{$i}( $args ) {
echo 'done';
}
endfor;
Any ideas on how I can do this in PHP?
Aaron source
share