PHP 4.0 Bug #5611: inside foreach() - array pointer as reported by key, current don't move.
| From: | root at php2 dot chek dot com | Date: | Fri, 14 Jul 2000 19:56:39 +0000 |
| Subject: | PHP 4.0 Bug #5611: inside foreach() - array pointer as reported by key, current don't move. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-24581@lists.php.net to get a copy of this message | ||
This output is from todays php4 snap. I have obtained the same output with
RC2, 4.0.0 and 4.0.1.
twinhead% php -q q.php
traverse using foreach...
sections with 2 paragraph(s): 1
sections with 2 paragraph(s): 1
sections with 2 paragraph(s): 2
traverse using old style while loop...
sections with 2 paragraph(s): 1
sections with 3 paragraph(s): 1
sections with 12 paragraph(s): 2
var_dump...
array(3) {
[2]=>
int(1)
[3]=>
int(1)
[12]=>
int(2)
}
-- begin included script --
<?php
$analysis = array( 3 => 1, 12 => 2, 2 => 1);
// $analysis[3]++;
// $analysis[12]++;
// $analysis[12]++;
// $analysis[2]++;
ksort($analysis);
echo "traverse using foreach...\n";
foreach($analysis as $stats) {
echo "sections with " . key($analysis) . " paragraph(s): " . $stats .
"\n";
From: chrism@four.net
From: chrism@four.net
Operating system: FreeBSD 3.5
PHP version: 4.0 Latest CVS (14/07/2000)
PHP Bug Type: Scripting Engine problem
Bug description: inside foreach() - array pointer as reported by key, current don't move.
This output is from todays php4 snap. I have obtained the same output with
RC2, 4.0.0 and 4.0.1.
twinhead% php -q q.php
traverse using foreach...
sections with 2 paragraph(s): 1
sections with 2 paragraph(s): 1
sections with 2 paragraph(s): 2
traverse using old style while loop...
sections with 2 paragraph(s): 1
sections with 3 paragraph(s): 1
sections with 12 paragraph(s): 2
var_dump...
array(3) {
[2]=>
int(1)
[3]=>
int(1)
[12]=>
int(2)
}
-- begin included script --
<?php
$analysis = array( 3 => 1, 12 => 2, 2 => 1);
// $analysis[3]++;
// $analysis[12]++;
// $analysis[12]++;
// $analysis[2]++;
ksort($analysis);
echo "traverse using foreach...\n";
foreach($analysis as $stats) {
echo "sections with " . key($analysis) . " paragraph(s): " . $stats .
"\n";