In Laravel 5

Laravel 5 String Helpers: Replacing the Last Occurrence of a Value

Dec 6, 2017

The replaceLast helper method is used to replace the last occurrence of a given string with another string in a larger string. It is the opposite of the replaceFirst method. All three parameters must be strings and are required. An example use of this method includes replacing the last occurrence of a word in a sentence. In addition, there is a global str_replace_last helper function available which provides a shortcut for calling the replaceLast method.
Laravel 5 String Helpers: ends_with global helper

Dec 6, 2017

The endsWith method in Laravel's Str class is used to check if a given string ends with any of the supplied characters. It returns true if the string ends with any of the characters, and false otherwise. You can use the endsWith method directly or the global ends_with helper function for convenience.
Checking if a String Ends with a Particular Value in Laravel -Laravel 5.5 String Helper Method: endsWith

Nov 30, 2017

The endsWith method in Laravel's Str class is used to check if a string ends with any of the supplied characters. It returns true if the string ends with any of the characters and false otherwise. You can also use it to check if a string ends with any alphabetical character by combining it with PHP's range function. Additionally, there is a global function called ends_with that serves as a shortcut to calling Str::endsWith.
Checking if a String Starts With a Particular Value in Laravel - Laravel 5.5 String Helper Method startsWith

Nov 30, 2017

The startsWith method in Laravel's Str class checks if a given string starts with any of the supplied needles. It works the opposite of the ends_with method, using the same rules. Laravel also provides a global starts_with helper function, which is a shortcut to calling Str::startsWith.
Generating URLs from Strings in Laravel - Laravel 5.5 String Helper Method "slug"

Nov 30, 2017

The slug method in Laravel's Str class allows you to format a given title into a URI slug. It will convert the title to ASCII characters, replace whitespace with a separator, and reduce multiple separators to a single one. It will also trim any leading or trailing whitespace or separators. The slug method has a default separator of "-", but you can customize it as well as specify the language. Additionally, Laravel provides a global str_slug helper function as a shortcut to calling Str::slug.
Laravel 5.5 String Helper Method: contains

Nov 30, 2017

The contains method in Laravel's Illuminate\Support\Str class allows you to check if any given elements exist within a string. By passing in a string and an array of elements, the method will return true if any of the elements are found in the string, and false otherwise. The method takes into account the case of both the string and the elements. Additionally, Laravel provides a global str_contains helper function that serves as a shortcut to calling Str::contains.
Laravel 5.5 String Helper Method: finish

Nov 30, 2017

The finish helper method ensures that a given value always ends with a provided character or string. This is especially useful when constructing URIs or file paths. The method can be combined with other string manipulation methods, like slug, to generate interesting results. Additionally, there is a global str_finish helper function that provides a shortcut to calling Str::finish.
Laravel 5.5 String Helper Method: kebab

Nov 30, 2017

The snake helper method is used to replace uppercase letters in a string with their lowercase variant, preceded by a - character. However, if the first character of the string is capitalized, it will be replaced without the - character. The kebab method removes excess whitespace from a string that is being converted. Both methods can be used interchangeably when using the - delimiter. Additionally, the kebab_case function serves as a shortcut for calling the Str::kebab method.
Laravel 5.5 String Helper Method: snake

Nov 30, 2017

The snake helper method in Laravel replaces all uppercase letters within a string with the lowercased variant, while prefixing them with a given delimiter. However, if the first character of the string is already capitalized, it will be replaced by the corresponding lowercased variant without the delimiter. The method also trims any extra whitespace from the string being converted. Additionally, there is a global snake_case helper function available, which is a shortcut to calling Str::snake.
Laravel 5.5 String Helper Method: title

Nov 30, 2017

This method allows you to convert a given value into a traditional print title format. It converts the value to lowercase and capitalizes the first character of each word. Note that it may change the case of every character in the string. In addition to the title method, you can also use the global title_case helper function as a shortcut for calling Str::title.
Laravel String Pattern Matching - Laravel 5.5 String Helper Method: "is"

Nov 30, 2017

The is helper method in Laravel's Illuminate\Support\Str class checks if a given value matches a given pattern. It returns true if the value matches the pattern and false otherwise. The method does not support traditional regular expressions. Laravel also provides a global str_is helper function that is a shortcut to calling Str::is.
Making Sure Strings Start With a Given Value in Laravel - Laravel 5.5 String Helper Method: start

Nov 30, 2017

The start helper method ensures that a given value begins with exactly one occurrence of a prefix. It can be useful for generating absolute URLs from relative paths. The prefix can be any string value. Additionally, there is a global str_start helper function that provides a shortcut for calling Str::start.
Laravel 5.5 String Helper Function: after

Nov 27, 2017

Learn how to use the after method in Laravel's Illuminate\Support\Str class to extract a substring after the first occurrence of a specified character. This method is useful for parsing URL query strings or quickly finding substrings based on a certain character. Use the provided signature and example to get started.
Laravel 5.5 String Helper Function: ascii

Nov 27, 2017

The ascii helper method converts a string in UTF-8 encoding into its ASCII equivalent. It is useful when communicating with software platforms that require ASCII or complying with formatting protocols. The method accepts a language parameter, and in Laravel 5.5, it supports Bulgarian and German in addition to English. The method can be used by passing a string to it and will return the ASCII representation of that string.

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.