Skip to content

Instantly share code, notes, and snippets.

@seriiserii825
Created July 21, 2017 23:11
Show Gist options
  • Save seriiserii825/c2072e5ee55004d00ed16aea9986caa0 to your computer and use it in GitHub Desktop.
Save seriiserii825/c2072e5ee55004d00ed16aea9986caa0 to your computer and use it in GitHub Desktop.
Function str_all_pos
function str_all_pos($haystack, $needle) {
$pos = 0;
$result = [];
while (false !== ($pos = strpos($haystack, $needle, $pos))) {
$result[] = $pos;
$pos = $pos + strlen($needle);
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment