|
Posted by Aerik on 06/07/07 16:29
Jon,
What are you trying to accomplish? Do you have a list of functions,
and you want to call each one if the probability of it being called is
above a certain threshold? If so, a very simple approach might be to
assign the probabilities and functions to an array.
See if this is what you're trying to do, or perhaps clarify it to me/
us:
$funcary[] = array('probability'=>.75, 'funcname'=>'function1');
$funcary[] = array('probability'=>.47, 'funcname'=>'function2');
$funcary[] = array('probability'=>.99, 'funcname'=>'function3');
$curprob = rand(0,100)/100;
foreach($funcary as $afunc=>$ary){
if ($afunc['probability'] < $curprob) $afunc['funcname']();
}
Where 'function1' etc. are the names of your functions. I didn't test
this at all, fyi, but I think it should work.
Aerik
Navigation:
[Reply to this message]
|