Finding of all occurrences of a substring in a string
It is possible to find all of the occurrences of a substring within a string using strpos method. Third argument in strpos method is the offset of the initial string. This parameter is optional, by default a substring will be searched in a string from its beginning. To find all the occurences of a substring, it is possible to make a loop, searching for a substring in different starting locations of a source string.
Comments
Post a Comment