Question: For some reason, I have a sorted php array:

```
"$arr_questions" = Array [6]    
    0   Array [6]   
    1   Array [6]   
    2   Array [6]   
    3   Array [6]   
    4   Array [6]   
    5   Array [6]   

```

each of the positions is another array. This time it is associative. See position [0]:

```
0 = Array [6]   
    question_id 40  
    question    La tercera pregunta del mundo   
    explanation 
    choices Array [3]   
    correct 0   
    answer  1   

```

Without looping my array, is there any way to access directly this position 0, just knowing one of its properties?

Example... Imagine I have to change some property of the position of the array whose "question\_id" property is 40. That is the only I know. I don't know if the question\_id property is gonna be in the first or second or which position. And, for example, imagine I want to change the "answer" property to 2.

How can I access directly to that position without looping the whole array. I mean... I don't want to do this:

```
foreach ($arr_questions as $question){
  if ($question["question_id"] == 40){
    $question["answer"] == 2;
  }
}

```

Answer: 
With your situation it's not possible without a loop, but if you change your array structure to this:

```
array(
    39 => array(...), 
    40 => array(...)
)

```

Which 39 and 40 are your `question_id`, then you can access them so fast without any loop.

If you want or have to to keep that structure, then just write a function to get the `array`, the `associative index` and the `value` you want as parameters to search the array and return the found index, so you will not be forced to write this loop over and over ...
No, there is no way to access that element without looping over your array. You might abstract that search into a helper function, however.