PHP函数根据属性随机输出图片

I am wondering if it's possible to output randomly some pictures if a certain attribute is added on a product. I am just learning php and I would like to test some things... Let's say I add 10 diffrent pictures of fish plates and I would like to output always 2 of them on a product page where the product has the attribute "fish" on food recommendation. How can I do this the most easiest way on PHP 5.6?