[ create a new paste ] login | about

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

PHP, pasted on Apr 7:
1
2
3
4
5
6
7
8
9
10
<?php

    $array = array(1, 2, 3, 4, 5);

    foreach ($array as $key => $item) {
      $array[$key + 1] = $item + 2;
      echo "$item\n";
    }

    print_r($array);


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


Create a new paste based on this one


Comments: