Random images with no duplicates (ACF Gallery) [closed]

Use array_unique() before foreach:

Edited:

<?php while ( have_posts() ) : the_post();

    $images = get_field('gallery');

    // thumbnail
    if( $images ): 
?>
    <ul id="container" class="tiles-wrap animated">
        <?php 
            $images = array_rand($images); 
            $images = array_unique($images); 

            foreach( $images as $image ): 

                // $rand_class = array('small', 'medium', 'large');
                $size="medium";
                $thumb = $image['sizes'][ $size ];
                $width = $image['sizes'][ $size . '-width' ];
                $height = $image['sizes'][ $size . '-height' ]; ?>

               <li><img src="https://wordpress.stackexchange.com/questions/184741/<?php echo $image["sizes']['medium']; ?>" alt="https://wordpress.stackexchange.com/questions/184741/<?php echo $image["alt']; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" /></li>       

            <?php endforeach;
       endif; ?>
    </ul>
<?php endwhile; ?>

error code: 523