I have a class with a callback. I pass a string to the class and the callback gets called with that string as the callback function. It works a little like this:
$obj->runafter( 'do_this' );
function do_this( $args ) {
echo 'done';
}
What I am looking to do is run this inside of a loop and so that the function doesn't get written multiple times I want to add a variable to the function name. What I want to do is 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 accomplish this in PHP?