Bug #14068 Updated: 2 while list each dont work

From: Date: Thu, 15 Nov 2001 12:29:44 +0000
Subject: Bug #14068 Updated: 2 while list each dont work
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-70558@lists.php.net to get a copy of this message
ID: 14068
Updated by: hholzgra
Reported By: witterstein@web.de
Old Status: Open
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.0.5
New Comment:

you have to reset() the arrays before
the loops start to reset the internal
array pointer (see http://php.net/each)

or better use the foreach loop instead
of while/each

Previous Comments:
------------------------------------------------------------------------

[2001-11-15 06:56:24] witterstein@web.de

<?php

$a[0]="x";
$a[1]="y";
$b[0]="z";
$b[1]="w";
$b[2]="u";

while (list($key,$val)=each($a) )
	{
		while (list($key2,$val2)=each($b) )
			{
				print "$key: $val - $key2: $val2<br>";
			}
	}
?>

'./configure' '--with-mysql' '--with-apache=../apache_1.3.20'
'--with-gd=../gd-1.8.3' '--enable-track-vars'

------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=14068&edit=1



Thread (5 messages)

« previous php.dev (#70558) next »