I am creating a basic foreach loop gallery function, but this gallery function I am trying to make is a little different because I am merging all the gallery images into one.
And there are multiple gallery arrays that I need to combine into one, however these gallery arrays are contained in one big array, and I'm struggling to figure out how to combine them because they are nested in the main array.
See how my array is structured below...
$gallerys = get_field( 'gallery_images' );
var_dump($gallerys);
-
array(2) {
[0]=>
array(2) {
["gallery_name"]=>
string(11) "Gallery One"
["gallery_images"]=>
array(1) {
[0]=>
array(10) {
["id"]=>
int(373)
...etc etc
}
}
}
[1]=>
array(2) {
["gallery_name"]=>
string(11) "Gallery Two"
["gallery_images"]=>
array(1) {
[0]=>
array(10) {
["id"]=>
int(542)
...etc etc
}
}
}
}
Can anyone point me in the right direction with updating the $gallerys variable with a new array which combines all ["gallery_images"] data into one.
So the idea is I can do this...
if( $gallerys ):
foreach( $gallerys as $gallery ):
echo $gallery['id'].'<br/>';
endforeach;
endif;
And it will output this...
373
542
Thanks in advance for any help you can provide.
Josh