[PHP 8]
str_starts_with — Checks if a string starts with a given substring
Description
str_starts_with[string $haystack
, string $needle
]: bool
Parameters
haystack
The string to search in.
needle
The substring to search for in the haystack
.
Return Values
Returns true
if haystack
begins with needle
, false
otherwise.
Examples
Example #1 Using the empty string
''
The above example will output:
All strings start with the empty string
Example #2 Showing case-sensitivity