hello all, 

I have an array like this:

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. (posted below) - Could
someone please help me out? im just not good enough to do this i
think... thanks very much indeed..


#### Nicks messed up code so far:

  function rubbish_function($machines) {
    while(count($machines) > 1) {
      for($i=0; $i<count($machines); $i++) {
        sequence[] = ($i+1) . ':' . rtrim($machines[$i][0]);
        array_shift($machines[$i]);
      }
      if(empty($machines[$i])) {
        array_shift($machines);
      } else rubbish_function($machines);
    }
    return $sequence;
  }

  
-- 
Nick W

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

Reply via email to