Req #51797 [Opn->Fbk]: valid arguments for foreach

From: Date: Tue, 11 May 2010 20:39:32 +0000
Subject: Req #51797 [Opn->Fbk]: valid arguments for foreach
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150352@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51797&edit=1

 ID:          51797
 Updated by:  degeberg@php.net
 Reported by: rc at opelgt dot org
 Summary:     valid arguments for foreach
-Status:      Open
+Status:      Feedback
 Type:        Feature/Change Request
 Package:     *General Issues
 PHP Version: 5.2.13

 New Comment:

The following script works fine for me:

<?php
$array = array(
	array('foo','bar'),
	array('test','hello'),
);

$i = 0;
foreach ($array[$i] as $key => $val) {
	echo $key . $val;
}
?>

You'll have to provide a complete script that gives unexpected/incorrect

warnings.


Previous Comments:
------------------------------------------------------------------------
[2010-05-11 18:25:31] rc at opelgt dot org

Description:
------------
When I give an array to loop through the name of the array and if the
array given 
is with a key, in this case $i, should make no difference.

PHP4 didnt make a warning, PHP5 instead does.

Test script:
---------------
foreach($array[$i] as $key => $val) results in an warning message.





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



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


Thread (5 messages)

« previous php.bugs (#150352) next »