Re: arrays and references

From: Date: Thu, 12 Oct 2000 15:58:28 +0000
Subject: Re: arrays and references
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-19829@lists.php.net to get a copy of this message
> // This is the important part > while ($row = mysql_fetch_array($result)) { > array_push($rows, $row); // is this correct, or would > // I want to push a "reference" > // to $row onto array $rows? This is correct! (dont use a reference) > > $rows = array(); > populate_rows($rows); > > $row_ct = 0; > while (list($key, $value) = each ($rows)) { > $row_ct++; > echo "Row $row_ct: ID=$rows[$row_ct][id], Name=$rows[$row_ct][name]<br>"; > } or use foreach( $rows as $key => $value){ echo "Row $key: ID=$value["id"], Name=$value["name"]<br>"; } bye -- Stefan - Zipkid - Goethals YourNet - Open source web design & Site management. http://www.yournet.be mailto:stefan@yournet.be

« previous php.general (#19829) next »