Php Loop Over Array Javascript Function