Printing out an element of stdClass Object

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
User avatar
cparekh
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 120
Joined: Mon Jan 14, 2008 10:48 am
Location: London, UK
Contact:

Printing out an element of stdClass Object

Postby cparekh » Tue Aug 19, 2008 2:12 pm

Hi,

a bit of a n00bie question here: I'm trying to print out an element of an array and I'm having trouble accessing it.

I'm querying a table using JFACTORY::getDBO() and a print_r of the result returns this:

Code: Select all

Array ( [0] => stdClass Object ( [title] => Infrastructure ) )


And what I'd like to do is print out 'Infrastructure'. What can I use to access it?

Thanks in advance for your help,
C.
Chandesh Parekh
Joomla & WordPress Web Development
twitter : http://www.twitter.com/chandeshparekh
web : http://chandeshparekh.com

User avatar
ircmaxell
Joomla! Ace
Joomla! Ace
Posts: 1926
Joined: Thu Nov 10, 2005 3:10 am
Location: New Jersey, USA
Contact:

Re: Printing out an element of stdClass Object

Postby ircmaxell » Tue Aug 19, 2008 6:53 pm

echo $var[0]->title;
Anthony Ferrara - Core Team - Development Coordinator - Bug Squad - JSST

http://moovum.com/ - The Bird is in the air! Get Mollom Anti-Spam on your Joomla! website with Moovur...
http://www.joomlaperformance.com For All Your Joomla Performance Needs

User avatar
cparekh
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 120
Joined: Mon Jan 14, 2008 10:48 am
Location: London, UK
Contact:

Re: Printing out an element of stdClass Object

Postby cparekh » Wed Aug 20, 2008 7:44 am

ircmaxell,

Thanx, that did it! :)
Chandesh Parekh
Joomla & WordPress Web Development
twitter : http://www.twitter.com/chandeshparekh
web : http://chandeshparekh.com


Return to “Joomla! 1.5 Coding”

Who is online

Users browsing this forum: No registered users and 5 guests