I'm trying to make a photo gallery with multiple galleries listed that I need to paginate.
So, this variable
$galleries = Photograph::find_by_sql($sql);
holds an array:
Array
(
[0] => Photograph Object
(
[id] =>
[gallery_name] => candies
)
[1] => Photograph Object
(
[id] =>
[gallery_name] => icecream
)
[2] => Photograph Object
(
[id] =>
[gallery_name] => pastries
)
[3] => Photograph Object
(
[id] =>
[gallery_name] => chocolate
)
)
(I've shortened it for convenience)
I'm using these two variables to set a selected gallery:
$newest_gallery = reset($galleries);
$gallery_name = (isset($_GET['subj']) ? $_GET['subj'] : $newest_gallery->gallery_name);
I was able to set the selected gallery by using the gallery_name, however, I'm unable to paginate the galleries since I need to somehow dynamically store a numerical index of an array element (which holds the gallery_name) into a variable in order to create the pagination function, since I need an integer value for this purpose. So, I basically need to get the index of an array element. Is there a way to do this?