Closed

The blogrums are now closed. If you wish to visit them on there new home then you can find it here ( InnerVisions Blogrums ).

AuthorSnippet

PHP:

<?php
var_dumplottery649 ) );
 
function lottery$number_required_balls$number_total_balls )
{
    $balls array();
    for( $i 1$i <= $number_total_balls$i++ )
    {
        $balls[] = $i;
        echo $i."\n"// remove when tested ;)
    }
    shuffle$balls );
    return array_slice$balls0$number_required_balls );
}
?>

I may have opened the door, but you entered of your own free will
image

 
Afwas
user avatar

Posts : 27

Location : Groningen, The Netherlands

Joined : 03/03/08 10:39 am

Posted on : 13/03/08 03:16 pm

PHP:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 array(6) { [0]=>  int(49) [1]=>  int(11) [2]=>  int(32) [3]=>  int(30) [4]=>  int(21) [5]=>  int(39) }
 
Afwas
user avatar

Posts : 27

Location : Groningen, The Netherlands

Joined : 03/03/08 10:39 am

Posted on : 13/03/08 03:16 pm

PHP:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 
array(6) { [0]=>  int(49) [1]=>  int(11) [2]=>  int(32) [3]=>  int(30) [4]=>  int(21) [5]=>  int(39) }
 
Afwas
user avatar

Posts : 27

Location : Groningen, The Netherlands

Joined : 03/03/08 10:39 am

Posted on : 13/03/08 03:19 pm

PHP:

function lottery$number_required_balls$number_total_balls )
    {
        $array_total_balls array();
        
        // Fill the array with numbers 1 - $number_required_balls (default 49)
        for ( $i 0$i $number_total_balls$i++ )
        {
            $j $i +1;
            // $array_total_balls[ $i ] = $i +1; doesn't seem to work
            $array_total_balls$i ] = $j;
        }
        //pick the balls
        $array_picked_balls array_rand$array_total_balls$number_required_balls );
        sort$array_picked_balls );
        
        //returns array
        return $array_picked_balls;
    }
 
¥åßßå
user avatar

Posts : 43

Location : 127.0.0.1

Joined : 03/03/08 10:38 am

Posted on : 13/03/08 03:19 pm

PHP:

shuffle$balls );
    $picked array_slice$balls0$number_required_balls );
    sort$picked );
    return $picked;
}

I may have opened the door, but you entered of your own free will
image

 
Afwas
user avatar

Posts : 27

Location : Groningen, The Netherlands

Joined : 03/03/08 10:39 am

Posted on : 13/03/08 03:19 pm

[quote="keljem"]That's Mint Afwas, cheers.
See it on my page http://garysblog.co.uk/

Just one bug, it picks out the random ball now and again as ball 0. I wouldn't know how to fix it but I bet you do ?

Here's hoping it picks the winning numbers this week ;)

Cheers
Gz[/quote]

 
¥åßßå
user avatar

Posts : 43

Location : 127.0.0.1

Joined : 03/03/08 10:38 am

Posted on : 13/03/08 03:21 pm

Lol, looks like I need to add quote to the bbcode for comments :p

¥

I may have opened the door, but you entered of your own free will
image

 
¥åßßå
user avatar

Posts : 43

Location : 127.0.0.1

Joined : 03/03/08 10:38 am

Posted on : 13/03/08 03:23 pm

PHP:

<?php
var_dumplottery649 ) );
 
function lottery$number_required_balls$number_total_balls )
{
    $balls array();
    for( $i 1$i <= $number_total_balls$i++ )
    {
        $balls[] = $i;
    }
    $picked array_rand$balls,$number_required_balls );
    sort$picked );
    return $picked;
}
?>

I may have opened the door, but you entered of your own free will
image

 
Afwas
user avatar

Posts : 27

Location : Groningen, The Netherlands

Joined : 03/03/08 10:39 am

Posted on : 13/03/08 03:39 pm

PHP:

<?php
    //var_dump( lottery( 6, 49 ) );
     $number_required_balls 6;
     $number_total_balls 49;
    {
        $balls array();
        for( $i 1$i <= $number_total_balls$i++ )
        {
            $balls[] = $i;
        }
        $picked array_rand$balls,$number_required_balls );
        sort$picked );
        print_r$picked );
        echo "\n\n";
    }
    ?>

XML:

Array ( [0] => 0 [1] => 4 [2] => 14 [3] => 20 [4] => 38 [5] => 46 )
 
Afwas
user avatar

Posts : 27

Location : Groningen, The Netherlands

Joined : 03/03/08 10:39 am

Posted on : 13/03/08 03:59 pm

OK, so array_rand returns keys