Here are the inputs I want to loop through
Main photo:
Side photo 1:
I'm way late to the game for this answer but I got tired of solving the problem of dealing with the PHP files array over and over, so I wrote a composer package so I'd never have to again. Maybe someone googling will find my answer and be happy.
Install tvanc/files-array-organizer
composer require tvanc/files-array-organizer
Pass $_FILES
to it, and it'll give you back an array that's structured the way you were expecting.
Main photo:
Side photo 1:
Side photo 2:
Side photo 3: