4

Friend posted this PHP snippet.

<?
$a=array(1,2,3);
foreach ($a as &$item){}
foreach ($a as $item){}
print_r($a);

The output is 1,2,2 - why?

Boaz
  • 18,950
  • 8
  • 62
  • 67
K2xL
  • 9,301
  • 15
  • 59
  • 97

0 Answers0