RE: Multi-dimensional arrays

Поиск
Список
Период
Сортировка
От tom
Тема RE: Multi-dimensional arrays
Дата
Msg-id 002001c0f9b2$a3355450$7f0f2c81@bellsouth.net
обсуждение исходный текст
Ответ на Multi-dimensional arrays  ("Hunter, Ray" <rhunter@enterasys.com>)
Список pgsql-php
for($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

В списке pgsql-php по дате отправления:

Предыдущее
От: "Hunter, Ray"
Дата:
Сообщение: Multi-dimensional arrays
Следующее
От: Laurent Patureau
Дата:
Сообщение: Do an Update without waiting for the result