I'm trying to add a class and <div> tags to part of an array. It's an array of different fields (images and text) from a number of child pages. I want the result of each child to be styled individually, but so far, I've only been able to style the whole array or each individual item.
I tried:
<div class="my-class">
<?php
foreach($page->children as $child):
foreach($child->images as $image):
echo "<img src='$image->url'/>";
endforeach;
endforeach;
?>
</div>
which adds a class to the whole array.
Or:
<?php
foreach($page->children as $child):
foreach($child->images as $image):
echo "<div class='my-class'> <img src='$image->url'/></div>";
endforeach;
endforeach;
?>
which adds a class to each individual field. I understand that I have to add something to the code that divides the array for each child page, but how?