note 15202 added to function.pg-fetch-array
| From: | rtreat2 at tampabay dot rr dot com | Date: | Fri, 31 Aug 2001 15:19:49 +0000 |
| Subject: | note 15202 added to function.pg-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17431@lists.php.net to get a copy of this message | ||
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
http://www.php.net/manual/en/function.pg-fetch-array.php