note 15202 deleted from function.pg-fetch-array by irchtml

From: Date: Sun, 09 Jan 2005 15:46:01 +0000
Subject: note 15202 deleted from function.pg-fetch-array by irchtml
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82989@lists.php.net to get a copy of this message
Note Submitter: rtreat2 at tampabay dot rr dot com ---- I think it should be emphasized that the second group of fields (with the field names as keys) are associative arrays and so the array you get from pg_fetch_array wont behave like a normal array. $sql = "select foo,bar from mytable"; $arr = pg_fetch_array($result); echo $arr[0]; // ex: NT echo $arr[1]; // ex: 98 echo $arr[foo]; // ex: NT echo $arr[bar]; // ex: 98 but if I do: for ($i=0;$i<count($arr);$i++){ $arr[$i] = "linux"; } you might think all 4 fields would be overwritten, but with this type of array we get: echo $arr[0]; // ex: linux echo $arr[1]; // ex: linux echo $arr[3]; // ex: linux echo $arr[4]; // ex: linux and yet... echo $arr[foo]; // ex: NT echo $arr[bar]; // ex: 98

« previous php.notes (#82989) next »