Laravel has great starts_with() helper. For example, this will return true:

starts_with('This is my name', 'This');
Answer from Alexey Mezenin on Stack Overflow
🌐
Laravel Daily
laraveldaily.com › post › laravel-string-helpers-open-source-examples
Laravel String Helpers: 16 Open-Source Examples
If you need to check whether a string starts with a given value, the Str::startsWith() helper is just for that.
🌐
DEV Community
dev.to › aleson-franca › a-deep-dive-into-laravel-str-helper-methods-3oii
A Deep Dive into Laravel: Str Helper Methods - DEV Community
March 17, 2025 - if (Str::contains('Laravel Framework', ... (Str::startsWith('Laravel Framework', 'Laravel')) { echo "Starts with Laravel"; } Truncates the string to the specified limit....
🌐
Darija-Coding
darija-coding.com › tutorial › how-to-check-if-a-string-starts-with-another-string-in-laravel-9
Darija Coding | How to Check If a String Starts with Another String in Laravel 9
The startsWith() method checks if the provided string starts with a specific word if yes it returns true otherwise it returns false. ... In this lesson, we will see how to add query parameters to Laravel pagination.Our goal in this lesso...
🌐
Souysoeng
souysoeng.com › home › laravel › laravel 10 check if string starts with specific value example
Laravel 10 Check If String Starts with Specific Value Example
May 1, 2025 - This method is part of Laravel's powerful Illuminate\Support\Str class and provides a clean way to perform string inspections. The Str::startsWith() method checks whether a given string begins with one or more specified substrings.
🌐
Stillat
stillat.com › blog › 2016 › 11 › 16 › laravel-string-helper-function-starts_with
Laravel String Helper Function: starts_with » Stillat
November 16, 2016 - startsWith is a helper method in Laravel that checks if a given string starts with any of the specified values. It is the opposite of the ends_with method and follows the same rules of use.
Find elsewhere
🌐
Laravel
laravel.com › docs › 12.x › strings
Strings | Laravel 12.x - The clean stack for Artisans and agents
after afterLast apa append ascii basename before beforeLast between betweenFirst camel charAt classBasename chopStart chopEnd contains containsAll decrypt deduplicate dirname doesntContain doesntEndWith doesntStartWith encrypt endsWith exactly excerpt explode finish fromBase64 hash headline initials inlineMarkdown is isAscii isEmpty isNotEmpty isJson isUlid isUrl isUuid kebab lcfirst length limit lower markdown mask match matchAll isMatch newLine padBoth padLeft padRight pipe plural position prepend remove repeat replace replaceArray replaceFirst replaceLast replaceMatches replaceStart replaceEnd scan singular slug snake split squish start startsWith stripTags studly substr
🌐
GitHub
gist.github.com › niraj-shah › 9dfdb34de7fc7a083b73
Laravel 5.x Custom Validation Rule: startswith · GitHub
Laravel 5.x Custom Validation Rule: startswith. GitHub Gist: instantly share code, notes, and snippets.
🌐
GitHub
github.com › laravel › nova-issues › issues › 1905
Error with `starts_with` after upgrading to Laravel 6.0 · Issue #1905 · laravel/nova-issues
September 9, 2019 - Laravel Version: 6.0.1 Nova Version: 2.2.0 PHP Version: 7.2 Description After upgrading from Laravel 5.8 to 6.0 (and therefore removing the string helpers), upgrading Nova to 2.2.0, and running php artisan nova:publish php artisan view:c...
Author: laravel
🌐
Laravel News
laravel-news.com › home › laravel tutorials › laravel's enhanced string validation with inverse methods
Laravel's Enhanced String Validation with Inverse Methods
August 26, 2025 - Laravel's new inverse string methods eliminate awkward negation logic, creating more intuitive and maintainable validation code. Moving Beyond Double Negatives Traditional string validation often required negating existing methods, creating mental overhead when reading conditions: use Illuminate\Support\Str; if (!Str::startsWith($document, ['draft_', 'temp_', 'backup_'])) { $this->processPublishedDocument($document); } if (!Str::endsWith($username, ['_admin', '_system', '_test'])) { $this->createStandardUser($username); } Laravel's inverse methods transform these conditions into clear, positiv
🌐
PHP
php.net › manual › en › function.str-starts-with.php
PHP: str_starts_with - Manual
str_starts_with — Checks if a string starts with a given substring · Performs a case-sensitive check indicating if haystack begins with needle
🌐
Medium
medium.com › @harrisrafto › laravels-string-methods-clean-inverse-matching-fdd8d26e2a30
Laravel’s String Methods: Clean Inverse Matching | by Harris Raftopoulos | Medium
August 12, 2025 - Laravel’s String Methods: Clean Inverse Matching String validation logic in Laravel often required negating startsWith() and endsWith() calls, leading to less readable conditions. The new …
🌐
Laravel
laravel.com › docs › 10.x › strings
Strings - Laravel 10.x - The PHP Framework For Web Artisans
September 11, 2023 - The Str::startsWith method determines if the given string begins with the given value:
🌐
Educative
educative.io › home › courses › using laravel for advanced string manipulation in php › checking if a string starts with another string
Check If a String Starts With Another Using Laravel
Learn how to use Laravel’s startsWith helper to check if a string begins with specified characters or substrings. Understand logical string checks.
🌐
GitHub
github.com › laravel › framework › issues › 2627
Standardize Str::startsWith() and endsWith() with empty needle · Issue #2627 · laravel/framework
November 3, 2013 - Currently, starts_with('foobar', '') throws a warning (and returns false) and ends_with('foobar', '') returns true. I think the warning should be removed, and the return value of these cases unified. And, per this answer on stackoverflow...
Author: laravel
🌐
GitHub
github.com › laravel › framework › issues › 57264
`@pushIf` with `Str::startsWith()` causes syntax error in Blade · Issue #57264 · laravel/framework
October 3, 2025 - Laravel Version 12.32.5 PHP Version 8.2.29 Database Driver & Version No response Description When using @pushIf in a Blade template with Str::startsWith(), a syntax error occurs: syntax error, unexpected token ":" This happens even when ...
Author: laravel