I have the following array structure with master data with thousands of records.
Array
(
[0] => 0,1
[1] => 0,0
[2] => 0,2
[3] => 0,3
[4] => 10,2
)
I have a second array with a smaller subset. Such as
Array
(
[0] => 0,1
[1] => 0,0
)
I would like to find second array in first array in the extact same order of elements present in second array. But rather than doing an intersect I would like to find the key (or keys) from first array as well. I have been wrecking my brain on this...
UPDATED:
The keys are unique . So far example in above array I would like to see output of:
Array2 found in array1 (starting at key 0).
Second Example:
Array
(
[a] => 0,1
[b] => 0,0
[c] => 0,2
[d] => 0,3
[e] => 10,2
)
second array
Array
(
[1] => 0,3
[2] => 10,2
)
expected output:
second array match in array A, starting at key d of array A..
hope that clears it.
print_r()to show it here? Are the array values unique? If so, you canarray_flipthe first array and loop for each value inb(O(n)) and look it up ina(O(1)). Also, perhaps array_intersect_assoc and array_intersect might help you.0,1is actually a string,"0,1"....