Re: Hi Friends

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 24 Oct 2005 20:10:28 +0200, José Miguel Santibáñez A.  
<jms@xxxxxxxxx> wrote:

>
>> 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";
> ?>
>

I hope this is not intended as a means of encryption.
Remember false security is worse than no security.
Heard of sha-1..?

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/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/
 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux