php - Merge multiple Array() depending loop and number -


i want merge 3 arrays.

my first 1 is:

array ( [0] => leaves-19 [1] => shifts-1 [2] => shifts-1 [3] => shifts-1 [4] => shifts-1 [5] => shifts-1 [6] => leaves-19 [7] => leaves-19 [8] => shifts-1 [9] => shifts-1 [10] => shifts-1 [11] => shifts-1 [12] => shifts-1 [13] => leaves-19 [14] => leaves-19 [15] => shifts-1 [16] => shifts-1 [17] => shifts-1 [18] => shifts-1 [19] => shifts-1 [20] => leaves-19 [21] => leaves-19 [22] => shifts-1 [23] => shifts-1 [24] => shifts-1 [25] => shifts-1 [26] => shifts-1 [27] => leaves-19 [28] => leaves-19 [29] => shifts-1 [30] => shifts-1 [31] => shifts-1 [32] => shifts-1 [33] => shifts-1 [34] => leaves-19 [35] => leaves-19 [36] => shifts-1 [37] => shifts-1 [38] => shifts-1 [39] => shifts-1 [40] => shifts-1 [41] => leaves-19 ) 

my second is:

array ( [0] => 2013-04-28 [1] => 2013-04-29 [2] => 2013-04-30 [3] => 2013-05-01 [4] => 2013-05-02 [5] => 2013-05-03 [6] => 2013-05-04 ) 

the third 1 is:

array ( [0] => 13 [1] => 10 [2] => 12 [3] => 9 [4] => 14 [5] => 11 ) 

i want:

  • 2013-04-28 / 13 / leaves-19
  • 2013-04-29 / 13 / shifts-1
  • 2013-04-30 / 13 / shifts-1
  • 2013-05-01 / 13 / shifts-1
  • 2013-05-02 / 13 / shifts-1
  • 2013-05-03 / 13 / shifts-1
  • 2013-05-04 / 13 / leaves-19
  • 2013-04-28 / 10 / leaves-19
  • 2013-04-29 / 10 / shifts-1
  • 2013-04-30 / 10 / shifts-1
  • 2013-05-01 / 10 / shifts-1
  • 2013-05-02 / 10 / shifts-1
  • 2013-05-03 / 10 / shifts-1
  • 2013-05-04 / 10 / leaves-19
  • ...

thansk help.


what tryed:

echo print_r($_post['daytype'])."<hr />"; echo print_r($_post['dayarr'])."<hr />"; echo print_r($_post['userarr'])."<hr />";  //echo count($_post['daytype'])." --- ".count($_post['dayarr'])." --- ".count($_post['userarr']);  // 2013-05-04 / 13 / leaves-19 $loopnb1 = count($_post['daytype']); $loopnb2 = count($_post['daytype'])/7;  for($a=0; $a<$loopnb1; $a++) {     echo $_post['daytype'][$a]."<br />"; }  echo "<hr />";  for($b=0; $b<$loopnb2; $b++) {     echo $_post['userarr'][1]."<br />"; } 

first/second/third arrays same pasted (same order).

$datescount        = count( $secondarray ); $firstarraylength  = count( $firstarray ); $thirdarraylength  = count( $thirdarray );  for( $i=0 ; $i < $thirdarraylength ; $i++ ) {     $currentthirdarrayvalue = $thirdarray[$i];      for( $inner=0, $firstarrayindex=0 ; $inner < $datescount ; $inner++, $firstarrayindex++ )     {         if( $firstarrayindex == $firstarraylength )                 $firstarrayindex = 0;          echo "{$secondarray[$inner]} / {$currentthirdarrayvalue} / {$firstarray[$firstarrayindex]}<br/>\n";     } } 

will give you:

2013-04-28 / 13 / leaves-19<br/> 2013-04-29 / 13 / shifts-1<br/> 2013-04-30 / 13 / shifts-1<br/> 2013-05-01 / 13 / shifts-1<br/> 2013-05-02 / 13 / shifts-1<br/> 2013-05-03 / 13 / shifts-1<br/> 2013-05-04 / 13 / leaves-19<br/> 2013-04-28 / 10 / leaves-19<br/> 2013-04-29 / 10 / shifts-1<br/> 2013-04-30 / 10 / shifts-1<br/> 2013-05-01 / 10 / shifts-1<br/> 2013-05-02 / 10 / shifts-1<br/> 2013-05-03 / 10 / shifts-1<br/> 2013-05-04 / 10 / leaves-19<br/> 

etc... ending with:

2013-05-01 / 11 / shifts-1<br/> 2013-05-02 / 11 / shifts-1<br/> 2013-05-03 / 11 / shifts-1<br/> 2013-05-04 / 11 / leaves-19<br/> 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -