Re: Newbie: Array of objects iteration
| From: | Tommy Pham | Date: | Fri, 09 Oct 2009 21:23:31 +0000 |
| Subject: | Re: Newbie: Array of objects iteration | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298825@lists.php.net to get a copy of this message | ||
----- Original Message ----
> From: MEM <talofo@gmail.com>
> To: MEM <talofo@gmail.com>; Fernando Castillo Aparicio <f_c_a_1980@yahoo.es>;
> Lester Caine <lester@lsces.co.uk>; php-general@lists.php.net
> Sent: Fri, October 9, 2009 6:22:05 AM
> Subject: RE: [PHP] Newbie: Array of objects iteration
>
> > 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
>
>
> Update:
>
> "PDO::FETCH_OBJ
> Returns an anonymous object with property names that correspond to the
> column names returned in your result set."
>
> I will give a shot on array_keys however, is there any method to access the
> PROPERTIES NAMES of a given object?
>
MEM,
http://www.php.net/language.oop5.reflection
Regards,
Tommy
>
> Regards,
> M.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php