I've got a class called Gallery that returns an arrayobject populated with Images as follows:
class Gallery {
function __construct() {
}
function getImages() {
$count = 0;
$rootfolder = 'fpss';
$images = new ArrayObject();
$dir = $rootfolder . "/images";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($filename = readdir($dh)) !== false) {
if (($filename != ".") && ($filename != "..")) {
$imageURL = $dir . "/" . $filename;
$image = new Image($imageURL);
$images->append($image);
}
}
closedir($dh);
}
}
return $images;
}
}
class Image {
function __construct($imageURL) {
$this->imagePath = $imageURL;
}
}
I'm then trying to loop through these and write them out on the page:
$gallery = new Gallery();
$images = $gallery->getImages();
foreach ($images as $image) {
echo $image->imageURL;
However, this doesn't write anything out. Any ideas why? Do I need to access the ArrayObject differently?