如何从数组的数组中获取价值

编程入门 行业动态 更新时间:2024-10-26 14:30:35
本文介绍了如何从数组的数组中获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有存储阵列的阵列。我需要从这个数组中提取特定的值。

I have an array of array stored. I need to extract the particular value from this arrays.

例如allarray包含数组列表allarray = [阵列[3],阵列[3],数组[3]是三阵列present

e.g allarray contain the list of arrays allarray= [Array[3],Array[3],Array[3]] are three arrays present in that.

0:数组[3] 0:A1 1:B1 2:C1

0:Array[3] 0:"a1" 1:"b1" 2:"c1"

1:数组[3] 0:A2 1:B2 2:C2

1:Array[3] 0:"a2" 1:"b2" 2:"c2"

3:数组[3] 0:A3 1:B3 2:C3

3:Array[3] 0:"a3" 1:"b3" 2:"c3"

我需要提取该C1,从上述阵列和显示在警报框c2和c3

I need to extract this c1,c2 and c3 from the above arrays and display in the alert box.

谁能告诉我,我该怎么办呢?

Can anyone tell me how i can do that?

我试着用$。每个可惜不工作。任何人都可以?

i tried with $.each but unfortunately doesn't work. Can anyone?

推荐答案

如果我理解正确,你的阵列看起来像这样

If I understand you correctly, your array looks like this

var allarray = [["a1","b1","c1"],["a2","b2","c2"],["a3","b3","c3"]];

要获得C1,C2和C3你可能只是做到这一点。

To get c1, c2, and c3 you could just do this

var c1 = allarray[0][2], c2 = allarray[1][2], c3 = allarray[2][2];

或你可以做一个循环来把所有的CS在自己的单个阵列

or you could do a loop to put all of the cs in a single array of its own

var cs = []; for(var i = 0; i < allarray.length; i++) { cs.push(allarray[i][2]); }

更多推荐

如何从数组的数组中获取价值

本文发布于:2023-11-26 22:11:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635406.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   组中   价值

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!