I want to find the intersection of elements between two arrays; the result will go to another array.
I've written: $result = array_intersect($arrayone,$arraytwo);
If I write count($result)
it returns a correct value, but if I write $result[0]
it returns the following notice: Notice: Undefined offset: 0
.
the intersection maintains index. do the following
$result = array_intersect($arrayone,$arraytwo);
$result = array_values($result);
Then you can access with $result[0];