> Hey Brian > > Thanks a lot for that idea, i got it and built my logic upon it thanks a > lot. > an OO aproach: <? class prandom { var $total = 0; var $values = array(); function prandom() { mt_srand((double)microtime()*1000000); } function add($key, $value) { $this->values[$key] = $value; $this->total += $value; } function generate() { if ($this->total > 0) { $rand = mt_rand(0, $this->total); $acum = 0; reset($this->values); do { list($k, $v) = each($this->values); $acum += $v; } while ($acum < $rand); return($k); } } } ?> an example: <? require_once('prandom.php'); $t = new prandom(); $t->add('often', 80); $t->add('infrequently', 15); $t->add('rarely', 2); for ($i = 0; $i < 100; $i++) echo $t->generate() . "\n"; ?> -- José Miguel Santibáñez jms@xxxxxxxxx ------------------------ Yahoo! Groups Sponsor --------------------~--> Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life. http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/saFolB/TM --------------------------------------------------------------------~-> PHP Data object relational mapping generator - http://www.meta-language.net/ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-objects/ <*> To unsubscribe from this group, send an email to: php-objects-unsubscribe@xxxxxxxxxxxxxxx <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/