note 51074 added to control-structures.foreach

From: Date: Fri, 18 Mar 2005 20:05:13 +0000
Subject: note 51074 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-86657@lists.php.net to get a copy of this message
It seems that foreach returns different variable types depending on which syntax you use and which version of PHP you are running. If you use this syntax: foreach($array as $key => $val) { then the $val variable is a string (or whatever the actual value in the array is). But if you use this syntax: foreach($array as $val) { then it appears that the $val variable is an array in PHP 4.3.10, and it is a string (or whatever) in versions 4.3.1, 4.3.2, and 4.3.6 (I haven't tested any other version). ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51074 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51074&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51074&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51074&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51074&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51074&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51074&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86657) next »