simpli Posted June 8, 2009 Share Posted June 8, 2009 Hi, I have some records that I return through a function as a rowset. I want to go through each row and echo it. I used zend's toarray function to turn the rowset into an set of arrays that I loop through. It was my understanding that this <td><?php echo $treePathRow->ancestor_id;?></td> would allow me to access the column ancestor_id of an row ( or in this case the array corresponding to it). In fact this it is that notation that works <td><?php echo $this->escape($treePathRow["ancestor_id"]);?></td> Isn't the '->' a valid way to get access to the data of an associative array? Thanks for clarifying. JR Quote Link to comment https://forums.phpfreaks.com/topic/161323-associative-arrays/ Share on other sites More sharing options...
gevans Posted June 8, 2009 Share Posted June 8, 2009 Try <td><?php echo $treePathRow["ancestor_id"] ?></td> I'm sure that's all you need Quote Link to comment https://forums.phpfreaks.com/topic/161323-associative-arrays/#findComment-851299 Share on other sites More sharing options...
RussellReal Posted June 8, 2009 Share Posted June 8, 2009 -> is to go inward into an object <?php class Frog { public $name: public function Frog($name) { $this->name = $name; } public function talk() { echo $this->name.' Says: Ribbit<br />'; } } $rudie = new Frog('Rudie'); $rudie->talk(); ?> $rudie is an instance of the Frog class... -> tells it to go inside $rudie(Frog) and use the function talk() which would echo Rudie Says: Ribbit<br /> to reference a element inside an associative array you use the same brackets you use on a numbered array $arrayVar['nameOfElement'] and for numbered it would be: $arrayVar[10] for the 11th Element Quote Link to comment https://forums.phpfreaks.com/topic/161323-associative-arrays/#findComment-851416 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.