[ create a new paste ] login | about

Link: http://codepad.org/bWufA3YT    [ raw code | output | fork ]

PHP, pasted on Jan 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php

  $array = range(0, 8);

  $result = array();

  for ($i = 0; $i < 3; $i++) {
    for ($j = $i; isset($array[$j]); $j += 3) {
      $result[] = $array[$j];
    }
  }

  print_r($result);


Output:
1
2
3
4
5
6
7
8
9
10
11
12
Array
(
    [0] => 0
    [1] => 3
    [2] => 6
    [3] => 1
    [4] => 4
    [5] => 7
    [6] => 2
    [7] => 5
    [8] => 8
)


Create a new paste based on this one


Comments: