i would like to know the proper way to do this
$dynValue=5;//loop this many times
//start of my loop
for ($num=1; $num <= $dynValue; $num++){
//note the incremented number ($num) in the call back
add_action('add_meta_boxes', 'mpc_meta_box_'.$num.');
//below is where im having the problem
// i am trying to increment this function name so i will not get the error that "function name has already been declared". i cannot add '.$num.' in the func name below cause its not valid php.
function mpc_meta_box_'.$num.'(){
//some content
}
}//end of my loop
i can do this with eval() but i know its not recommeneded
You can try something like this:
Use always the same function as callback. You may use a static variable inside of the function to track how often it was called:
But I think you need to find a better architecture.