I don't follow. Is this really the intended behavior? It seems quite unintuitive that the original array would be modified by *empty* loops.

Suppose I create an include file that loops through $_GET variables with references:
foreach ($_GET as &$get) { /* empty loop */ }

Subsequent foreach() loops on $_GET would cause corruption. Seems dangerous.

When would this behavior be desired?

!intuitive && !desired == bug ?

Richard

On Oct 21, 2009, at 8:19 PM, mm w wrote:

Richard, enumerator exhausted, repeat your sub-sequence again you will get it
e.g pointer and pointed


<?php
$items = array('apple', 'banana', 'carrot');
print_r($items);
foreach ($items as &$item) { }
print_r($items);
foreach ($items as $item) { }
print_r($items);


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to