make better foreach snippet in php
let php snippet works in web mode