Created
July 21, 2017 23:11
-
-
Save seriiserii825/c2072e5ee55004d00ed16aea9986caa0 to your computer and use it in GitHub Desktop.
Function str_all_pos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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