In article <[EMAIL PROTECTED]>, Nick Wilson wrote:
> array (
>         1 => array(123, 345, 454), 
>         2 => array(8854, 393, 4947, 77, 3343), 
>         3 => array(393, 33)
>       );
> 
> I need to create an array sequence from that that would look like this:
> array (
>         '1:123', 
>         '2:8854', 
>         '3:393', 
>         '1:345', 
>         '2:393', 
>         '3:33', 
>         '1:454', 
>         '2:4947', 
>         '3:393',    // notice this has started from the start again...
>         '1:123',    // as has this..
>         '2:77', 
>         etc etc 
>       );
> 
> untill the last number of the largest array (number 2 in
> the original array) have been used.
> 
> I do have some code to show you but im afraid ive been going at it all
> the wrong way so im not sure it's of any use. 

Do you have a clue what your code is doing? Or did you just come up with
it? What is the use of writing code that you don't understand?

Not going to do your homework, but will give you some hints:

it seems your function accepts an array as parameter, and returns a new
array. 

to find the largest number, you could say the first number in the array
is the current biggest. And then you loop through all the values, and remember
the array number when you meet a value that is greater than the current
biggest.

Now it's only a matter of building the new array, and resetting your
index to 0 when it's as big as the biggest found earlier.

http://www.php.net/functions
http://www.php.net/foreach


-- 
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>

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

Reply via email to