RE: [PHP] Newbie: Array of objects iteration

From: Date: Fri, 09 Oct 2009 12:15:50 +0000
Subject: RE: [PHP] Newbie: Array of objects iteration
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-298805@lists.php.net to get a copy of this message
>Correct about my example, although I'm not sure if you get each record as an array or as an object. Anyway, you can iterate both. > >And if you want to get the column names, I suppose you could use array_keys() on the first record if you receive an array, or maybe get_object_vars() if it's an >objecs (note that with this you get an array with keys and values). > >I've found PDOStatement->getColumnMeta(). There's a big fat warning saying this is experimental, but you could take a look in case you need more data on the >columns. > >Hope it helps. Right now, I have something like this: foreach ($objRecord as $record) { //we will have a new line. $xls_file .="\n"; foreach ($record as $column=>$value) { $xls_file .= $value."\t"; } } The only thing I need now, is to put on top, the column names, and I have myself a xls file. YUpii!! I just need the column names... I will take a look on those functions you have mentioned. Thanks a lot, :) Márcio

« previous php.general (#298805) next »