nerdexam
Zend

200-530 · Question #40

You have been given the following PHP code snippet: <?php $array = array ('1', '2', '3'); foreach ($array as $key => $value) { $value = 4; } print_r($array); ?> What will be the output? Zend 200-530…

The correct answer is C. Array ( [0] => 1 [1] => 2 [2] => 3 ). See the full explanation below for the reasoning.

Question

You have been given the following PHP code snippet: <?php $array = array ('1', '2', '3'); foreach ($array as $key => $value) { $value = 4; } print_r($array); ?> What will be the output? Zend 200-530 Exam

Exhibit

200-530 question #40 exhibit

Options

  • AArray ( [0] => 4 [1] => 8 [2] => 12 )
  • BThe script will throw an error message.
  • CArray ( [0] => 1 [1] => 2 [2] => 3 )
  • DArray ( [0] => 1 [4] => 2 [8] => 3 )

How the community answered

(35 responses)
  • A
    3% (1)
  • B
    6% (2)
  • C
    77% (27)
  • D
    14% (5)

Community Discussion

No community discussion yet for this question.

Full 200-530 Practice