Php Loop Over Array Javascript Function Syntax