Hello Brian,
You created an array with image name and url but then you scan the directory with images.
Do you want to show random flag?
You can randomize it without scanning the directory. Also please read my comments in the code. You created smarty condition in php file!
Use my file!