Trying to get custom post type attachment images to function in indexed array

Managed to find a solution that display the array correctly:

$attachments = get_children( array(
    'post_parent'    => get_the_ID(),
    'post_type'      => 'attachment',
    'numberposts'    => -1,
    'post_status'    => 'inherit',
    'post_mime_type' => 'image',
    'order'          => 'ASC',
    'orderby'        => 'menu_order ASC'
    ) );

    $imgArray = array();
    $counter = 0;
    foreach ( $attachments as $attachment_id => $attachment ) {

    $imgArray[$counter] = $attachment_id;
    $counter++;
    if($counter > 2) {
    break;
    }
    } 
?>
<div class="attachment1"><?php echo wp_get_attachment_image( $imgArray[0], 'medium'); ?></div>
<div class="attachment2"><?php echo wp_get_attachment_image( $imgArray[1], 'medium'); ?></div>
<div class="attachment3"><?php echo wp_get_attachment_image( $imgArray[2], 'medium'); ?></div>