note 19641 deleted from function.extract by aidan
| From: | aidan@php.net | Date: | Thu, 09 Sep 2004 09:14:49 +0000 |
| Subject: | note 19641 deleted from function.extract by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76295@lists.php.net to get a copy of this message | ||
Note Submitter: phplist at jzdev dot com
----
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