I'm trying to find the index based on the value stored within it.
This would normally be easy, but the array I'm working with is highly nested. Each index 0,1,2
has fields f1,f2,f3
. I'm trying to find which index 0,1,2
has in its f2
field the value this
stored in it. In this case, it's index 0
. So that's the output I'm looking for. Is there a neat trick in PHP to do this effectively?
$somearray[0][f1] = "not this";
$somearray[0][f2] = "this";
$somearray[0][f3] = "not this";
$somearray[1][f1] = "not this";
$somearray[1][f2] = "not this";
$somearray[1][f3] = "not this";
$somearray[2][f1] = "not this";
$somearray[2][f2] = "not this";
$somearray[2][f3] = "not this";