Re: Newbie: Array of objects iteration

From: Date: Fri, 09 Oct 2009 06:23:09 +0000
Subject: Re: Newbie: Array of objects iteration
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-298789@lists.php.net to get a copy of this message
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

« previous php.general (#298789) next »