I am facing a strange problem. It may just be a silly mistake, and I am just missing some basics.
I'm running php 5.6.1 on MAMP.
I have a simple array which I get from a mysql query. Using a foreach loop, I can print_r() each value, which gives me: stdClass Object ( [srno] => 6 [link] => this-is-link )
Now I can echo $obj->srno, and that prints fine. But I can't use echo $obj['srno'] which I was previously using, on an older version of PHP, but- It shows nothing.
Any help really appreciated. Thanks!
ArrayAccessstdClassobjects and you can't access stdClass object's property likearray. If your query returns an array of arrays then you are able to access that as an array, so the question is what are you using for yourDBquery? Probably you can change the return type toArrayinstead ofstdClass.->in PHP is not a pointer !!!result()to return rows. I am sure I was able to use the same code before. Something changed in php 5.6.1?