You are here: Re: function "attributes" « PHP Programming Language « IT news, forums, messages
Re: function "attributes"

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация