Re: Newbie: Array of objects iteration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fernando Castillo Aparicio wrote:
I think you are just looking for the key in the wrong place. Try:

foreach ( $records as $record ) { foreach( $record as $column=>$value ) {
        echo "$column is $value\n";
    }
}

You've got the columns names in each record, not in the global recorset.

print_r($record); often helps - you can see what is actually returned and check that you have names rather than numbers for the fields ;)

print_r($records); becomes a little large if you have a lot of results so use with care :)

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux