Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Count the number of substring occurrences
<?php substr_count(    string $haystack,    string $needle,    int $offset = 0,    ?int $length = null): int
<?php         $targetDirLoader = null;

        $mainAutoload = $rootPackage->getAutoload();

        if ($rootPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {

            $levels = substr_count($filesystem->normalizePath($rootPackage->getTargetDir()), '/') + 1;

            $prefixes = implode(', ', array_map(function ($prefix) {

                return var_export($prefix, true);

            }, array_keys($mainAutoload['psr-0'])));
<?php             if (is_string($token)) {

                $output .= $token;

            } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {

                $output .= str_repeat("\n", substr_count($token[1], "\n"));

            } elseif (T_WHITESPACE === $token[0]) {


                $whitespace = Preg::replace('{[ \t]+}', ' ', $token[1]);
<?php         }



        $commonPath = rtrim($commonPath, '/') . '/';

        $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/');

        $commonPathCode = str_repeat('../', $sourcePathDepth);



        return ($commonPathCode . substr($to, \strlen($commonPath))) ?: './';
<?php         if (strpos($to, $from.'/') === 0) {

            return '__DIR__ . '.var_export(substr($to, \strlen($from)), true);

        }

        $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/') + $directories;

        if ($staticCode) {

            $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";

        } else {
<?php             $ip6 = substr($hostName, 1, $index - 1);

            $hostName = substr($hostName, $index + 1);



            if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {

                return $error;

            }

        }
<?php             }

        }



        if (substr_count($hostName, ':') === 1) {

            $index = strpos($hostName, ':');

            $port = substr($hostName, $index + 1);

            $hostName = substr($hostName, 0, $index);
<?php     private static function certNameMatcher($certName)

    {

        $wildcards = substr_count($certName, '*');



        if (0 === $wildcards) {