note 19641 added to function.extract

From: Date: Wed, 06 Mar 2002 18:05:10 +0000
Subject: note 19641 added to function.extract
Groups: php.notes 
Request: Send a blank email to php-notes+get-27421@lists.php.net to get a copy of this message
Be careful when using extract() on an array that may contain null values. Say you're in a loop and overwrite the vars each time through. You'd expect the vars to contain whatever value you would get if you accessed the array directly. This doesn't happen. Null values won't overwrite the last value. Example: Datbase contains FieldA FieldB 10 20 NULL 50 25 20 while ($row = mysql_fetch_array($rs)) { extract($row, EXTR_PREFIX_ALL, "IN"); echo $IN_FieldA.", ".$IN_FieldB."\n"; } Output: 10, 20 10, 50 25, 20 -- http://www.php.net/manual/en/function.extract.php http://master.php.net/manage/user-notes.php?action=edit+19641 http://master.php.net/manage/user-notes.php?action=delete+19641 http://master.php.net/manage/user-notes.php?action=reject+19641

« previous php.notes (#27421) next »