substr_count

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Count the number of substring occurrences
substr_count(    string $haystack,    string $needle,    int $offset 0,    ?int $length null): int
    public static function substrCount($haystack$needle$offset 0$length null)

    {

        if (! 
is_null($length)) {

            return 
substr_count($haystack$needle$offset$length);

        } else {

            return 
substr_count($haystack$needle$offset);

        }
        if (! is_null($length)) {

            return 
substr_count($haystack$needle$offset$length);

        } else {

            return 
substr_count($haystack$needle$offset);

        }

    }
        $query EloquentTestUser::has('postWithPhotos');



        
$bindingsCount count($query->getBindings());

        
$questionMarksCount substr_count($query->toSql(), '?');



        
$this->assertEquals($questionMarksCount$bindingsCount);

    }
        }




        if (
substr_count($directoryDIRECTORY_SEPARATOR) === 1) {

            return 
is_dir($directory) ? $directory self::DEFAULT_TESTS_PATH;

        }
        while ($matchesCount 0) {

            
$orderByPos          $matches[0][--$matchesCount][1];

            
$openBracketsCount   substr_count($query'('$orderByPos);

            
$closedBracketsCount substr_count($query')'$orderByPos);

            if (
$openBracketsCount === $closedBracketsCount) {

                return 
false;
        while ($matchesCount 0) {

            
$orderByPos          $matches[0][--$matchesCount][1];

            
$openBracketsCount   substr_count($query'('$orderByPos);

            
$closedBracketsCount substr_count($query')'$orderByPos);

            if (
$openBracketsCount === $closedBracketsCount) {

                return 
false;

            }
        $repo null;

        
$id $reference;



        if (
substr_count($id'::')) {

            [
$repo$id] = explode('::'$id2);

        }
    public function process($data)

    {

        if (
substr_count($data"\n") > || substr_count($data': ') > 0) {

            
$data \Statamic\Facades\Yaml::parse($data);

        }
        $folders->sort(function ($a$b) {

            return (
substr_count($a'/') >= substr_count($b'/')) ? -1;

        });
        $dir str_finish($this->directory'/');

        
$relative str_after(Path::tidy($file->getPathname()), $dir);



        return 
$file->getExtension() === 'yaml' && substr_count($relative'/') === 0;

    }



    public function 
makeItemFromFile($path$contents)
        $filename str_after(Path::tidy($file->getPathName()), $this->directory);



        return 
substr_count($filename'/') === && $file->getExtension() === 'yaml';

    }



    public function 
makeItemFromFile($path$contents)
        $filename str_after(Path::tidy($file->getPathName()), $this->directory);



        return 
substr_count($filename'/') === && $file->getExtension() === 'yaml';

    }



    public function 
makeItemFromFile($path$contents)
        $path Str::after($path$this->directory);

        
$path Str::before($path'.yaml');



        if (
substr_count($path'/') === 0) {

            return [
Site::default()->handle(), $path];

        }
    {

        
$filename str_after(Path::tidy($file->getPathName()), $this->directory);



        return 
$file->getExtension() === 'yaml' && substr_count($filename'/') === 0;

    }



    public function 
makeItemFromFile($path$contents)
                foreach (Folder::getFilesRecursively($folder) as $path) {

                    
$slashes substr_count($path'/') - substr_count($folder'/');



                    if (
$slashes <= $depth) {

                        
$folder_files[] = $path;