diff --git a/content/php/concepts/string-functions/terms/str-starts-with/str-starts-with.md b/content/php/concepts/string-functions/terms/str-starts-with/str-starts-with.md new file mode 100644 index 00000000000..42462d7d848 --- /dev/null +++ b/content/php/concepts/string-functions/terms/str-starts-with/str-starts-with.md @@ -0,0 +1,62 @@ +--- +Title: 'str_starts_with()' +Description: 'Performs a case-sensitive search to check if a string starts with a given substring.' +Subjects: + - 'Web Development' + - 'Web Design' + - 'Computer Science' +Tags: + - 'Strings' + - 'Functions' +CatalogContent: + - 'learn-php' + - 'paths/computer-science' +--- + +The **`str_starts_with()`** function is used to perform a case-sensitive search to check whether a string starts with a given substring. + +## Syntax + +```pseudo +$stringstartswith = str_starts_with($str, $substring); +``` + +The `$str` represents the input string to check. + +The `$substr` represents the substring to search for in the input string. + +The `str_starts_with()` function returns true if the `$str` starts with the `$substr` or false otherwise. + +## Example + +The example below demonstrates `str_starts_with()` operating on the same string in three ways (single character, multiple characters, and a case-sensitive example). + +```php + +``` + +This will result in the following output: + +```shell +the string Peanut Butter Jelly begins with P. +the string Peanut Butter Jelly begins with Peanut. +the string Peanut Butter Jelly does not begin with p. +```