Welcome Guest, Not a member yet? Register   Sign In
Array of Array ?
#1

[eluser]Unknown[/eluser]
Can someone help me with the following?

In my controller I have;

Code:
$this->load->model('Flickr');
$data['photos'] = $this->Flickr->get_published_photos();
$this->load->view('tearsheets', $data);

And in my model I have;

Code:
$photos = array();

foreach ($photoset['photoset']['photo'] as $photo) {

// Store data for use in the view
$photos = array ('title' => $photo['title'],
                 'photo_medium' => $f->buildPhotoURL($photo, 'medium')
                 'photo_square' => $f->buildPhotoURL($photo, 'square'));

}
return $photos;

The problem I have having is that when I look at $data['photos'] in the controller, then I only get the last record.

What do I need to change in the model so that all of the data is stored in $photos?

Thanks
#2

[eluser]aquary[/eluser]
You are redeclaring $photos again inside the loop. Put [] to make array of array.

Code:
$photos[] = array ('title' => $photo['title'],
                 'photo_medium' => $f->buildPhotoURL($photo, 'medium')
                 'photo_square' => $f->buildPhotoURL($photo, 'square'));

}
#3

[eluser]Unknown[/eluser]
Lovely. Many thanks.




Theme © iAndrew 2016 - Forum software by © MyBB