Based on how you describe your goals, you will likely need to replace the <img src=’’> with your own version of the icons (for example, create your own /img/icons/ folder and then do <img src='/img/icons/{$icon}.png'> where $icon would be the filename for the .png (and also would be whatever the definition of $icon actually is in the PHP, likely passed in as something like “moon” or “sun” based on what you describe)
This is just a quick way of doing it, but based on what you’re trying to really do, there will likely be much better ways to implement - this is just to show you what is going on here.
Say you wanted to do it using CSS, you could do something like this in place of the <img>(just an example):
<div class=’{$icon}’></div>
and then in CSS:
div.moon { background: url(‘url_to_moon.png‘); }
In the above .moon would be whatever the $icon variables are as it loops through the foreach. This would allow you to create your own images.