note 105622 added to language.operators.assignment

From: Date: Thu, 01 Sep 2011 14:19:40 +0000
Subject: note 105622 added to language.operators.assignment
Groups: php.notes 
Request: Send a blank email to php-notes+get-182880@lists.php.net to get a copy of this message
When using <php while ($var = current($array) { #do stuff next($aray) ?> to process an array, if current($array) happens to be falsy but not === false it will still end the loop. In such a case strict typing must be used. Like this: <php while (($var = current($array)) !== FALSE) { #do stuff next($aray) ?> Of course if your array may contain actual FALSE values you will have to deal with those some other way. ---- Server IP: 192.41.42.26 Probable Submitter: 136.224.46.191 ---- Manual Page -- http://www.php.net/manual/en/language.operators.assignment.php Edit -- https://master.php.net/note/edit/105622 Del: integrated -- https://master.php.net/note/delete/105622/integrated Del: useless -- https://master.php.net/note/delete/105622/useless Del: bad code -- https://master.php.net/note/delete/105622/bad+code Del: spam -- https://master.php.net/note/delete/105622/spam Del: non-english -- https://master.php.net/note/delete/105622/non-english Del: in docs -- https://master.php.net/note/delete/105622/in+docs Del: other reasons-- https://master.php.net/note/delete/105622 Reject -- https://master.php.net/note/reject/105622 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182880) next »