preg_match_all to get all occurrences of a string
- by i5z
I am trying to find offset of all occurrences with preg_match_all
e.g.
$haystack = 'aaaab';
$needle = 'aa';
preg_match_all('/' . $needle . '/', $haystack, $matches);
$matches is
Array
(
[0] => Array
(
[0] => Array
(
[0] => aa
[1] => 0
)…