While using PHP it's hard to keep guessing the contents of any $value that you're playing about with.
Recently @nielslange showed me how to make this much easer with a simple debug function:
https://gist.github.com/FreshLondon/b376cd0815153b0449ec5ec2e8209f53
By placing this short snippet (I'd recommend in your functions.php file, then you can later use this debug again) you can then use:
debug($yourValueHere);
on any $value in your PHP to see the contents!
Here's an example:
https://gist.github.com/FreshLondon/037ba6c2328deea26509c3960c4598e9
Now reloading that PHP file shows the associated values to $images neatly within <pre> tags.
In my case, this showed the contents of $images as:
https://gist.github.com/FreshLondon/99c7a289543580a4029303ee1d938481
With the above information we can quickly write out our PHP without relying on guessing. Effective, thanks Niels!