Php Loop Over Array Javascript Length Converter