Php Loop Over Key Value Array Javascript Length