Hi,
I know the both of the above are kinds of arrays which have been retrieved from the database. Why is there 2 different ways to approach it and what's better?
Thanks.
What's the different between $x->y and between $x['y']?
Moderator: General Moderators
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Have a look at the manual's classes and objects entry. There are also plenty of OOP tutorials on the web to check out. Both arrays and objects can be used to store database information (or any other kind of data), though they aren't comparable in many aspects.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
when using functions such as mysql_fetch_assoc() and mysql_fetch_object() there is very little difference. Generally I always use mysql_fetch_object() because the arrow syntax (->) uses one less character and, more importantly, you can add behaviour to objects but you can't add behaviour to arrays. If I wanted to add behaviour and I was using an array I'd have to change all the subscript syntax ([]) to arrow syntax first, and that is a hassle you can easily avoid.