note 44251 added to language.references.whatdo
| From: | lars at riisgaardribe dot dk | Date: | Mon, 19 Jul 2004 20:49:54 +0000 |
| Subject: | note 44251 added to language.references.whatdo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73623@lists.php.net to get a copy of this message | ||
A comment to pbaltz at NO_SPAM dot cs dot NO_SPAM dot wisc dot edu:
The following code did not work as I expected either:
while ( $row = mysql_fetch_array( $result ) ) {
// ... do something ...
// Now store the array $row in an array containing all rows.
$result_array[] = &$row; // I dont want to copy - there is a lot of data in $row
}
var_dump ( $result_array ) shows that all stored values now are "false" as this is the
last value of $row.
Instead the code should be:
while ( $row = mysql_fetch_array( $result ) ) {
// ... do something ...
$result_array[] = &$row;
unset ( $row ); //breaks the linkage between $row and a line in $result_array
}
Hope this is understandable/usefull
----
Manual Page -- http://www.php.net/manual/en/language.references.whatdo.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44251
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44251&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44251&report=yes
Search -- http://master.php.net/manage/user-notes.php