substr_count

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         while ($matchesCount > 0) {

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

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

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

            if ($openBracketsCount === $closedBracketsCount) {

                return false;
<?php         while ($matchesCount > 0) {

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

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

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

            if ($openBracketsCount === $closedBracketsCount) {

                return false;

            }