I've two A and B arrays, first one (A) is simple array where as the second one (B) is array of arrays. I want to find whether some element in A is equal to element in B. For doing this I'm currently doing nested loops which results in n^3 complexity. How can I improve upon this.
for ($i = 0; $i <= count($A); $i++) {
if (isset($A[$i])) {
foreach ($B as $items) {
foreach ($items as $item) {
if ($item['Column1'] == $A[$i]['Column1']) {
array_push(A, "result");
unset($A[$i]);
unset($items);
break;
}
}
}
}
}