'ACF : delete a field nested inside a group

I am trying to programatically delete an image sub field of a Group field element in ACF. Group field name is img_gallery and the image field inside it that needs to be deleted is img2. These 2 codes is what I have tried separately but to no avail. No error is thrown, yet no effect is taking place.

delete_sub_field(array('img_gallery', 1, 'img2'), 314);

delete_field('img2', 314);

Group field -> Image Field



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source