Flex 关联数组
用户输入一个逗号分隔的字符串和 id,以创建一个关联数组,如下所示: 输入:4,3,3,2,2 输出: Array{"0"=>4,"1"="3","2"=>3,"3"=>2,"4"=>2}
我可以通过以下方式创建一个数组输入.text.split(",");
但我想将其设为上面的关联数组,该怎么做?
谢谢。
User inputs a comma separated string and i d like to make a an associative array out of it as follows :
Input : 4,3,3,2,2
Output : Array{"0"=>4,"1"="3","2"=>3,"3"=>2,"4"=>2}
I can create an array by input.text.split(",");
But I d like to make it an associative array as above, how to do this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,除了这样的事实之外,像您所拥有的那样的数组已经是“关联的”——与从 0 开始的数字关联。所以:
如果您想与其他东西关联——比如字符串——那么您可能需要查看
Dictionary
类< /a>.Well, besides the fact that an array like the one you've got there is already 'associative' -- associated with numbers starting at 0. So:
If you want to associate with something else -- like strings -- then you might want to look into the
Dictionary
class.