admin管理员组

文章数量:1420220

I've the following array:

$test[$iterator][1][2]['name']

I have a function that needs to get $iterator of that array when ['name'] == 'value';

So how can I use Javascript to get the given $iterator?

Also, I did look at other questions, but I'm not sure if their answers apply to my question.

I've the following array:

$test[$iterator][1][2]['name']

I have a function that needs to get $iterator of that array when ['name'] == 'value';

So how can I use Javascript to get the given $iterator?

Also, I did look at other questions, but I'm not sure if their answers apply to my question.

Share Improve this question edited Jul 22, 2012 at 18:38 Jared Farrish 49.3k17 gold badges99 silver badges107 bronze badges asked Jul 22, 2012 at 18:33 AdolaAdola 5887 silver badges21 bronze badges 1
  • PHP or JavaScript? The $ seems a little strange. – Ry- Commented Jul 22, 2012 at 18:39
Add a ment  | 

1 Answer 1

Reset to default 8

Are you looking for something like this?

var $iterator;
for (var i = 0; i < $test.length; i++) {
    if ($test[i][1][2]['name'] == 'value')
    {
        $iterator = i;
        break;
    }
}

本文标签: jqueryJavascript get key of multidimensional arrayStack Overflow