I have an array $shraniKastomFildove
like this:
array(4) { [0]=> string(12) "hashed_token" [1]=> string(17) "registration_time" [2]=> string(12) "noviCustmDev" [3]=> string(2) "no" }
And an array $namesOfCustomFieldsUserWatsToUpdate
like this:
array(1) { [0]=> string(12) "noviCustmDev" }
I want to find index of matching element in $shraniKastomFildove
. In this case it would be 2, since under index of 2 element with "noviCustmDev" value is stored.
Here is how I tried to get it:
foreach($namesOfCustomFieldsUserWatsToUpdate as $nesto){
foreach($shraniKastomFildove as $dF){
if($dF==$nesto){
var_dump(key($shraniKastomFildove));
}
}
}
But here it dumps number 3. I'm wondering is there a better and more efficient way to get exact value, 2 in this case, or is it due to key()
counting indexes for 1 and not from 0?