PHP: is there a way to invoke case-insensitive substr_count()? -


just question says:

is there way invoke case-insensitive substr_count()?

there not native way, can do:

substr_count(strtoupper($haystack), strtoupper($needle)); 

you can of course write function:

function substri_count($haystack, $needle) {     return substr_count(strtoupper($haystack), strtoupper($needle)); } 

be aware of turkey test when using case changes compare strings.

http://www.moserware.com/2008/02/does-your-code-pass-turkey-test.html

from above:

as discussed lots , lots of people, "i" in turkish behaves differently in languages. per unicode standard, our lowercase "i" becomes "İ" (u+0130 "latin capital letter dot above") when moves uppercase. similarly, our uppercase "i" becomes "ı" (u+0131 "latin small letter dotless i") when moves lowercase.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -