fork(1) download
  1. <?php
  2.  
  3. $myArray = [
  4. 0 => [
  5. 'id' => 1,
  6. 'title' => 'title1'
  7. ],
  8. 1 => [
  9. 'id' => 2,
  10. 'title' => 'title2'
  11. ],
  12. 2 => [
  13. 'id' => 3,
  14. 'title' => 'title3'
  15. ],
  16. 3 => [
  17. 'id' => 4,
  18. 'title' => 'title4'
  19. ]
  20. ];
  21.  
  22.  
  23.  
  24. foreach ($myArray as $key => $item)
  25. {
  26. $myArray[$key]['funcResult'] = $item['id'];
  27. }
  28. unset($key);
  29.  
  30.  
  31. print_r($myArray);
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
<pre>Array
(
    [0] => Array
        (
            [id] => 1
            [title] => title1
            [funcResult] => 1
        )

    [1] => Array
        (
            [id] => 2
            [title] => title2
            [funcResult] => 2
        )

    [2] => Array
        (
            [id] => 3
            [title] => title3
            [funcResult] => 3
        )

    [3] => Array
        (
            [id] => 4
            [title] => title4
            [funcResult] => 4
        )

)
</pre>