可能重复:
根据插入顺序迭代哈希值?
即时尝试获取此哈希的第五个元素
%cds = ("Dr. Hook" => "Sylvias Mother",
"Rod Stewart" => "Maggie May",
"Andrea Bocelli" => "Romanza",
"Kenny Rogers" => "For the good times",
"Bee Gees" => "One night only",
"Bonnie Tyler" => "Hide your heart");
Run Code Online (Sandbox Code Playgroud)
在这种情况下,它将是"bee Gees","仅限一晚"
但是当我试图实现这个代码
while (($key, $value) = each %cds) {
print "$key $value\n";
}
Run Code Online (Sandbox Code Playgroud)
这会打印所有元素,但不按顺序排列
这怎么可能以及如何获得第五个元素?
| 归档时间: |
|
| 查看次数: |
6368 次 |
| 最近记录: |