pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedMulti-dimensional arrays
2+ messages / 2 participants
[nested] [flat]
* Multi-dimensional arrays
@ 2001-06-20 15:46 Hunter, Ray <rhunter@enterasys.com>
0 siblings, 1 reply; 2+ messages in thread
From: Hunter, Ray @ 2001-06-20 15:46 UTC (permalink / raw)
To: pgsql-php
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@enterasys.com
www.enterasys.com
^ permalink raw reply [nested|flat] 2+ messages in thread
* RE: Multi-dimensional arrays
@ 2001-06-20 17:58 tom <tom@outervention.net>
parent: Hunter, Ray <rhunter@enterasys.com>
0 siblings, 0 replies; 2+ messages in thread
From: tom @ 2001-06-20 17:58 UTC (permalink / raw)
To: 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@postgresql.org
[mailto:pgsql-php-owner@postgresql.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@enterasys.com
www.enterasys.com
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-06-20 17:58 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-20 15:46 Multi-dimensional arrays Hunter, Ray <rhunter@enterasys.com>
2001-06-20 17:58 ` tom <tom@outervention.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox