Re: [PHP] Re: Randomize an array?

2005-03-07 Thread Brian Dunning
http://www.php.net/shuffle
Boy do I feel stupid. Thanks!!  :)
I always RTFM and STFW before posting - but somehow did not search the 
PHP site for the word "shuffle." 
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Randomize an array?

2005-03-07 Thread Rick Fletcher
Brian Dunning wrote:
On Mar 7, 2005, at 7:40 AM, M. Sokolewicz wrote:
array_rand()

But that's likely to give me the same element more than once. I want to 
output the entire array but in a random order, like a shuffled deck of 
cards.
like a shuffled deck of cards?
http://www.php.net/shuffle
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: Randomize an array?

2005-03-07 Thread Jay Blanchard
[snip]
> array_rand()

But that's likely to give me the same element more than once. I want to 
output the entire array but in a random order, like a shuffled deck of 
cards.
[/snip]

Wow,. http://www.php.net/shuffle

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Randomize an array?

2005-03-07 Thread Brian Dunning
On Mar 7, 2005, at 7:40 AM, M. Sokolewicz wrote:
array_rand()
But that's likely to give me the same element more than once. I want to 
output the entire array but in a random order, like a shuffled deck of 
cards.

- Brian
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Randomize an array?

2005-03-07 Thread M. Sokolewicz
Brian Dunning wrote:
I have a Magpie RSS feed in an array, and I want to output it in random 
order. What's the best (fastest) way to do this?

- Brian
easiest:
array_rand()
http://www.php.net/array_rand
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: randomize etc?

2002-08-01 Thread Philip Hallstrom

split should work fine... Just do something like:

$teamMembersArray = split(" ,;", $textarea);

That will give you an array of the team members.  Of course I'm assuming
that their names don't include spaces and that you'll separate them with
either a space, comma, or semi-colon.  And you'll want to get rid of any
newlines in $textarea as well.

-philip

On Thu, 1 Aug 2002, Hawk wrote:

> I'm trying to make a small script that I can use for randomizing teams and
> stuff, I have one field where I enter how many teams, one for how many in
> each team, and a  to write down all the players in. This is where
> my brain stopped working, first I was thinking about using split, but I
> don't know how when there isn't a predefined number of variables to split it
> into, how do I do this?
>
> and when I have separated them into variables, how do I put them into
> arrays?
> or maybe that's not a good way to do it? I don't know, and the heat in my
> room is killing me, can't think clearly :)
>
> Håkan
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Re: randomize?

2002-05-10 Thread Dan Hardiker

[..]
>>> is there any way to limit to 4 in each group without 47839 rows of
>>> code?
[..]
>> yes. you can. ;)
[..]
> oh, thank you very much :P
[..]

This might be a bit more helpful ;) There are several way to do it, this
is just one. Unoptimised, aimed at readability.
= $groups) $cnt = 0;
}
// Return
return $return;
  }

  // Replace these with the items you want, and specifiy 4 groups
  $items = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14);
  $result = randGroup($items, 4);

  echo ""; print_r($result); echo "";

?>

-- 
Dan Hardiker [[EMAIL PROTECTED]]
ADAM Software & Systems Engineer



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: randomize?

2002-05-10 Thread Hawk

oh, thank you very much :P


"George Nicolae" <[EMAIL PROTECTED]> skrev i meddelandet
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> yes. you can. ;)
>
> --
>
>
> Best regards,
> George Nicolae
> IT Manager
> ___
> PaginiWeb.com  - Professional Web Design
> www.PaginiWeb.com
>
>
> "Hawk" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I have a group table with 16 items, and I want them to be randomly put
in
> 4
> > different groups, with 4 in each group, I've seen the $rand(x,x) thing,
> but
> > is there any way to limit to 4 in each group without 47839 rows of code?
> :P
> >
> > Håkan
> >
> >
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: randomize?

2002-05-10 Thread George Nicolae

yes. you can. ;)

--


Best regards,
George Nicolae
IT Manager
___
PaginiWeb.com  - Professional Web Design
www.PaginiWeb.com


"Hawk" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have a group table with 16 items, and I want them to be randomly put in
4
> different groups, with 4 in each group, I've seen the $rand(x,x) thing,
but
> is there any way to limit to 4 in each group without 47839 rows of code?
:P
>
> Håkan
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php