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
Yes, if you do a combination of $.inArray
and $.map
:
if ($.inArray(value, $.map(arr, function(v) { return v[0]; })) > -1) {
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With