If you are trying to do something different with each image based on the number then the best way to do this is to do that inside of the loop.
$count = 0; // keep track of what image is being used
foreach ($cabin_photo_gallery as $image) {
if ($count < 5) {
// one of first 5
} else {
// the rest
}
}