Comma separated all attached image ID numbers except featured image ID number

If we want to exclude the featured post image then here’s the one-liner updated:

$ids = join( ',', wp_filter_object_list( get_attached_media('image' ), [ 'ID' => get_post_thumbnail_id() ], 'NOT', 'ID' ) );

here it’s expanded:

$ids = join( 
    ',',                                       // join array by comma
    wp_filter_object_list( 
        get_attached_media('image' ),          // fetch attached images
        [ 'ID' => get_post_thumbnail_id() ],   // filter ID equal to featured image ID
        ' NOT',                                // filter operator: NOT
        'ID'                                   // pluck the IDs (only include)
    ) 
);