Note that somewhat similar error was discussed on this list a few months
ago[1]. You could probably have solved it yourself if you searched the mailing
list archives.
- Matijn
[1] http://www.mail-archive.com/php-general@lists.php.net/msg269552.html
---
Thanks Matijn, I missed that discussion,
Requesting that will at least require a major-release (f.e. PHP 6.0) ... but I
would rather request to add a notice or warning to the documentation of
references to remind stuff like that.
http://www.php.net/manual/en/language.references.php
I think this is stuff more people will stumble over ...
2012/3/25 Arno Kuhl :
>
> will not only give the wrong result, it will corrupt the array for *any*
> further use of that array. I still think it’s a bug according to the
> definition of foreach in the php manual. Maybe php needs to do an implicit
> unset at the closing brace of the foreach where
On Sun, Mar 25, 2012 at 4:11 PM, Arno Kuhl wrote:
> From: Simon Schick [mailto:simonsimc...@googlemail.com]
> Sent: 24 March 2012 12:30 AM
> To: Robert Cummings
> Cc: a...@dotcontent.net; php-general@lists.php.net
> Subject: Re: [PHP] foreach weirdness
>
> 2012/3/23 Robert Cummings
>>
>> On 12-03
[snip]
a necessary part of building the structure. It can be removed but only as a
post process. Why does it have to be removed? You can loop through the
structure in JavaScript without paying heed to the key's value.
>
> If it absolutely must go... you need to recurse through the final structur
From: Simon Schick [mailto:simonsimc...@googlemail.com]
Sent: 24 March 2012 12:30 AM
To: Robert Cummings
Cc: a...@dotcontent.net; php-general@lists.php.net
Subject: Re: [PHP] foreach weirdness
2012/3/23 Robert Cummings
>
> On 12-03-23 11:16 AM, Arno Kuhl wrote:
>>
>>
>> it still does not produce
> See this following example that illustrates the problem:
> $array = array(0, 1, 2, 3, 4, 5, 6);
> foreach ($array as $index=>$value) {
> if ( ($index+1) < count($array) ) {
> $array[$index+1] += $value;
> }
> echo $value." ";
> }
> echo "";
> foreach ($array as
7 matches
Mail list logo