Loop through nested array in Twig
Do you have control over your array structure? 

Why not just change it to this:

[
  0 =&gt; ['alt' =&gt; 'alt text', 'img' =&gt; 'image-path'],
  1 =&gt; ...?
]


Because then your logic would work, but right now you have the reversed structure. What you could do is loop over the image paths with {% for key, path in gallery_images.img %} and use the key toaccess gallery_iamges.alt[key]` (not 100% sure about the exact syntax). Certainly more complicated that way.