Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  5] [ 4]  / answers: 1 / hits: 15900  / 12 Years ago, mon, february 11, 2013, 12:00:00

I have a 2d array in the format



emi_309 | present | weak   | 6
emi_310 | present | strong | 9
emi_319 | present | medium | 8
emi_315 | present | weak | 5


I want to check if a value exists in the first column using a simple function



E.g, check if emi_77 exists in the first column



I came across $.inArray(value, array) but this function is for a 1d array only.



Is there something similar for 2d array


More From » jquery

 Answers
12

Yes, if you do a combination of $.inArray and $.map:



if ($.inArray(value, $.map(arr, function(v) { return v[0]; })) > -1) {
// ...
}

[#80295] Saturday, February 9, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ervindouglasm

Total Points: 451
Total Questions: 103
Total Answers: 102

Location: Turkmenistan
Member since Thu, Dec 1, 2022
1 Year ago
;