substr_count
laravel/framework
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
);
}
src/Illuminate/Support/Str.php
if (!
is_null
(
$length
)) {
return
substr_count
(
$haystack
,
$needle
,
$offset
,
$length
);
} else {
return
substr_count
(
$haystack
,
$needle
,
$offset
);
}
}
src/Illuminate/Support/Str.php
$query
=
EloquentTestUser
::
has
(
'postWithPhotos'
);
$bindingsCount
=
count
(
$query
->
getBindings
());
$questionMarksCount
=
substr_count
(
$query
->
toSql
(),
'?'
);
$this
->
assertEquals
(
$questionMarksCount
,
$bindingsCount
);
}
tests/Database/DatabaseEloquentIntegrationTest.php