arrays of objects

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm having considerable trouble finding the proper syntax for accessing  
a specific element from an object which is in an array.  Here is my  
pertinent code snippet:

         $courses = array();  // define empty array
         while(($row = mysql_fetch_object($result))) {
             array_push($courses,$row); // push row object onto the array
    echo "<p>$courses[0]->name</p>\n"; // access first object's name

This does not give me the string I want, which is name of the first  
course in the array.  I verified $courses[0] is an object.  One of the  
members of the object is 'name'.  How do I access the name of the first  

I tried:

and other combinations I could think of.  Which way is the correct way?


Re: arrays of objects

Rainman wrote:
Quoted text here. Click to load it

print "<p></p>";


Re: arrays of objects

Quoted text here. Click to load it
Yep!  That works!  thanks!

Site Timeline