Return to Snippet

Revision: 47598
at June 11, 2011 01:10 by jferiante

Initial Code
$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 = "";

$it = new RecursiveArrayIterator($book);

foreach ($it as $key=>$val)
echo $key.":".$val."\n";

Initial URL

Initial Description
I was trying to figure out the easiest way to loop through an object with PHP. Here it is.... RecursiveArrayIterator()

Initial Title
PHP Loop Through An Array

Initial Tags

Initial Language