What are the common pitfalls when working with substr_count() function in PHP for string manipulation?
One common pitfall when working with substr_count() function in PHP is not considering case sensitivity. By default, the function is case-sensitive, so it may not count all occurrences of a substring if the case doesn't match. To solve this issue, you can use strtolower() or strtoupper() functions to normalize the case before counting.
$string = "Hello world, hello PHP!";
$substring = "hello";
// Count occurrences of substring in a case-insensitive manner
$count = substr_count(strtolower($string), strtolower($substring));
echo $count; // Output: 2