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
  • 19,892
  • 8
  • 62
  • 70
K2xL
  • 9,730
  • 18
  • 64
  • 101

0 Answers0