Continue the loop elsewhere in the site : <p>this code causes the images to be displayed on a rotating basis on the site.</p>

<pre><code>&lt;?php
$myImagesList = array (
 'image1.png' ,
  'image2.png' ,
  'image3.png' ,
  'image4.png' ,
  'image5.png' ,
  'image6.png' ,
  'image7.png' ,
  'image8.png' ,
  'image9.png' ,
  'image10.png'
);

shuffle ($myImagesList);
echo '&lt;div style = "background: #0600ff" class = "div02"&gt;';
for ($i=0; $i&lt;10; $i++) {
    if ($i &lt; 5) {
      echo '' . $myImagesList[$i] . '';
    }
    if ($i == 5) {
       echo '&lt;/div&gt;';

        echo '&lt;div style = "background: #0600ff" class = "div02"&gt;';
     }  
     if ($i &gt; 5) {
        echo '' . $myImagesList[$i] . '';
      }
  }
 echo '&lt;/div&gt;';
?&gt;
</code></pre>

CONTENT

<p><strong>It is that way in html page</strong>
<a href="https://i.stack.imgur.com/3pQXf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3pQXf.png" alt="enter image description here"></a></p>

<p>But how to break this code so that the loop with rotating images continues elsewhere on the site?</p>

<p><strong>something like this</strong></p>

<pre><code>&lt;?php
RANDOM IMAGES 
?&gt;

XXX HTML CODE XXX

&lt;?php
CONTINUOUS RANDOM IMAGE
?&gt;
</code></pre>

<p><strong>imagem:</strong>
<a href="https://i.stack.imgur.com/Ix31A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ix31A.png" alt="enter image description here"></a></p>
