From: | "tom" <tom(at)outervention(dot)net> |
---|---|
To: | "'Pgsql-php \(E-mail\)'" <pgsql-php(at)postgresql(dot)org> |
Subject: | RE: Multi-dimensional arrays |
Date: | 2001-06-20 17:58:39 |
Message-ID: | 002001c0f9b2$a3355450$7f0f2c81@bellsouth.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
Multi-dimensional arraysfor($I=0;
$row=pg_fetch_array($result,$I,PGSQL_ASSOC); $I++){
$resultArray[]=$row; // Results in a scalar array with nested
associative arrays
}
return $resultArray;
You could also go a step further and manipulate each element of $row inside
the for loop, with another loop:
for( ... ){
while(list($key, $val)=each($row)){
// play with each field element here...
}
}
That said, my personal preference is to do it in a while loop instead of a
for loop, I think there was some reason why PHP preferred this, although I
can't remember why offhand.
$I=0;
while($I < pg_numrows($result)){
$row=pg_fetch_array($result,$I,PGSQL_ASSOC);
$resultArray[]=$row;
$I++;
}
return $resultArray;
-----Original Message-----
From: pgsql-php-owner(at)postgresql(dot)org
[mailto:pgsql-php-owner(at)postgresql(dot)org]On Behalf Of Hunter, Ray
Sent: Wednesday, June 20, 2001 11:47 AM
To: Pgsql-php (E-mail)
Subject: [PHP] Multi-dimensional arrays
Is there any way to get the result from a query into a multi-dimensional
array that can be done in a for loop.
RAY HUNTER
Automated Test Group
Software Support Engineer
ENTERASYS NETWORKS
Internal: 53888
Phone: 801 887-9888
Fax: 801 972-5789
Cellular: 801 698-0622
E-mail: rhunter(at)enterasys(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Laurent Patureau | 2001-06-21 09:42:20 | Do an Update without waiting for the result |
Previous Message | Hunter, Ray | 2001-06-20 15:46:53 | Multi-dimensional arrays |