PHP shuffle, multiple loop
<p>I want to shuffle 2 loops (or function) in the same correct order, in PHP.</p>

<p>The code currently looks like:</p>

<p><code>&lt;div class="overlay"&gt;</code></p>

<pre><code>&lt;?php

    // Get the list of all files with .jpg extension in the directory and save it in an array named $images
    $directory = "uploads/_gallery/*.jpg";

    // Create an array of images found in the uploads directory
    $images = glob($directory);

    // Randomise/shuffle the images
    shuffle($images);

    foreach( $images as $image ):
        if ($image) { ?&gt;
            &lt;div class="slide"&gt;
                &lt;?php echo "&lt;img src='" . $image . "'&gt;"; ?&gt;
            &lt;/div&gt;
        &lt;? }
    endforeach;

?&gt;
</code></pre>

<p><code>&lt;/div&gt;</code></p>

<p><code>&lt;div class="grid"&gt;</code></p>

<pre><code>&lt;?php

    // Get the list of all files with .jpg extension in the directory and save it in an array named $images
    $directory = "uploads/_gallery/thumbs/*.jpg";

    // Create an array of images found in the uploads directory
    $images = glob($directory);

    // Randomise/shuffle the images
    shuffle($images);

    foreach( $images as $image ):

        if ($image) { ?&gt;
            &lt;figure class="unit_25"&gt;
                &lt;?php echo "&lt;img src='" . $image . "'&gt;"; ?&gt;
            &lt;/figure&gt;
        &lt;? }

    endforeach;

?&gt;
</code></pre>

<p><code>&lt;/div&gt;</code></p>

<p>I've tried creating two separate image arrays and merging those with Shuffle, but no luck.</p>