/ Published in: PHP
I was trying to figure out the easiest way to loop through an object with PHP. Here it is.... RecursiveArrayIterator()
Expand |
Embed | Plain Text
$book = new stdClass();//perfunctory $book->title = "Harry Potter and the Prisoner of Azkaban"; $book->author = "J. K. Rowling"; $book->publisher = "Arthur A. Levine Books"; $book->amazon_link = "http://www.amazon.com/dp/0439136369/"; $it = new RecursiveArrayIterator($book); foreach ($it as $key=>$val)
You need to login to post a comment.
