|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-07-12 18:23 UTC] elmicha@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 17:00:01 2025 UTC |
Description: ------------ The foreach loop exits early and sets the $status variable to "". The problem is fixed by changing $status = $status && status( $b ); to $status &= status( $b ); Hope this is bogus :) I have tried this on WinXP PHP4.3.3RC1 and FREEBSD PHP4.3.1 both give the same result. Eric Reproduce code: --------------- <? function status( $c ) { echo $c; if( $c == 'two' ) return 0; return 1; } $a = array( 'one ','two ','three ','four ' ); $status = 1; foreach( $a as $b ) { $status = $status && status( $b ); } echo " foreach stopped. Status = ".$status; if( isset( $status ) ) echo " set "; else echo "unset"; ?> Expected result: ---------------- onetwothreefour foreach stopped. Status = 0 set Actual result: -------------- onetwo foreach stopped. Status = set