my code causes the images to appear randomly within the page. But how to insert an \"element\" (in my case would be a div) between these images?
Go with the most readable solution - the one that doesn't make you fall and debug later when changing something.
$splitAtNumber = 2; // or dynamically use count($myImagesList) / 2 or ....
// output first part of the array
for ($i = 0; $i < $splitAtNumber; $i++) {
echo '';
}
// Output your content
echo 'content';
// Output second part of the array
for ($i = splitAtNumber; $i < count($myImagesList); $i++) {
echo '';
}