note 44251 deleted from language.references.whatdo by colder

From: Date: Sat, 24 Feb 2007 11:46:41 +0000
Subject: note 44251 deleted from language.references.whatdo by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123823@lists.php.net to get a copy of this message
Note Submitter: lars at riisgaardribe dot dk ---- 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

« previous php.notes (#123823) next »