National_Instruments
200-500 · Question #204
What will the $array array contain at the end of this script? 1 <?php 2 function modifyArray (&$array) 3 { 4 foreach ($array as &$value) 5 { 6 $value = $value + 1; 7 } 9 $value = $value + 2; 10 } 12…
The correct answer is B. 2, 3, 6. See the full explanation below for the reasoning.
Question
What will the $array array contain at the end of this script? 1 <?php 2 function modifyArray (&$array) 3 { 4 foreach ($array as &$value) 5 { 6 $value = $value + 1; 7 } 9 $value = $value + 2; 10 } 12 $array = array (1, 2, 3); 13 modifyArray($array); 14 ?>
Options
- A2, 3, 4
- B2, 3, 6
- C4, 5, 6
- D1, 2, 3
How the community answered
(64 responses)- A8% (5)
- B84% (54)
- C5% (3)
- D3% (2)
Community Discussion
No community discussion yet for this question.