Get the number of occurrences of substring in the given string.

string:count_substring(STRING $string, STRING $substring) : INT

string:count_substring('hello my good good friend','good')
#=> 2

string:count_substring('hello my good good friend','enemy')
#=> 0

# note: it is case sensitive
string:count_substring('hello my good good friend','Friend')
#=> 0

# note: if you provide empty substring it will always return 0
string:count_substring('hello my good good friend','')
#=> 0

Copyright ©2013-2022 SunSed®. All rights reserved.