php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14068 2 while list each dont work
Submitted: 2001-11-15 06:56 UTC Modified: 2001-11-15 07:38 UTC
From: witterstein at web dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.5 OS: Linux
Private report: No CVE-ID: None
 [2001-11-15 06:56 UTC] witterstein at web dot 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'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-15 07:29 UTC] hholzgra@php.net
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
 [2001-11-15 07:29 UTC] bate@php.net
Andrey Hristov:

Try
reset($a); before the first while, and reset($b) just before the second in 
the body if the first.
 [2001-11-15 07:38 UTC] derick@php.net
Non-Bugs are bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 06:01:31 2024 UTC