For example:
main array is: array(0 => 'A', 1 => 'A', 2 => 'B', 3 => 'B', 4 => 'B');
pattern is: array('A', 'B');
expected answer: array( array(0, 2), array(1, 3) )
one more example:
main array array(0 => 'F', 5 => 'G', 78 => 'R', 2 => 'D');
pattern array('G', 'R', 'F');
expected answer: array(array(5, 78, 0))
How can I find all occurrences of pattern in array?
array(0, 2)
andarray(1, 3)
mean? – Rocket Hazmat Jul 10 '12 at 16:02array(0, 2)
. The0
is the index ofA
in the pattern array. and2
is the number ofA
s in the main array? – Rocket Hazmat Jul 10 '12 at 16:06array(0, 2)
the0
is the index ofA
in the main array, and2
is the index ofB
in the main array – Yekver Jul 10 '12 at 16:10