The Blog

Laravel 5

Laravel 5

Laravel 5.5 String Helper Method: snake

John Koster
John Koster
November 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

Laravel 5.5 String Helper Method: title

John Koster
John Koster
November 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 5

Laravel String Pattern Matching - Laravel 5.5 String Helper Method: "is"

John Koster
John Koster
November 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.

Laravel 5

Making Sure Strings Start With a Given Value in Laravel - Laravel 5.5 String Helper Method: start

John Koster
John Koster
November 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

Laravel 5.5 String Helper Function: after

John Koster
John Koster
November 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

Laravel 5.5 String Helper Function: before

John Koster
John Koster
November 27, 2017

The before method in Laravel's Illuminate\Support\Str class allows you to retrieve a portion of a string before the first occurrence of a specified character. It is useful for parsing URL query strings or extracting substrings. For example, Str::before('https://stillat.com?ref=newsletter', '?') would return "https://stillat.com".

Laravel 5

Laravel 5.5 String Helper Function: camel_case

John Koster
John Koster
November 27, 2017

The camel method in Laravel's Str class converts a string to camel case, where each word starts with a capitalized letter, except the first character, which is lowercased. It ignores special characters and spaces. The camel_case function is a shorthand for using Str::camel globally.

Laravel 5

Laravel 5.5 String Helper Function: studly

John Koster
John Koster
November 27, 2017

Learn how to format text using studly caps in Laravel. Studly caps removes word separators and capitalizes the first letter of each word. See examples of how the studly method works and how it can be used to generate Pascal Cased style strings. Also, find out about the global studly_case helper function that calls the Str::studly method.

Laravel 5

Laravel 5.5 String Helper Function: ascii

John Koster
John Koster
November 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.

Latest posts

Where Things get Good: Moving on to Forte Development Phase 1

Wrapping up Forte Phase 0 with the lexer and parser now in private alpha, and kicking off Phase 1 wi...

Read more
Forte Update: Backtracking, Metadata, HTML Validation, and More

A Forte development update: the parser now supports backtracking, improvements to node metadata, ide...

Read more
Parsing HTML and Blade Attributes in Forte

Wrapping up attribute parsing in Forte's HTML parser, from simple HTML attributes to complex, edge-c...

Read more
Switch Statements and Parser Extensions in Forte

Exploring how Forte's parser extensions can be used to handle complex Blade directives like nested s...

Read more
Parsing Blade Comments in Forte

Digging into parsing Blade and HTML comments while building Forte's HTML parser for Laravel Blade.

Read more
Thoughts on HTML Elements and Blade Components in Forte

This week I’m tackling Forte's HTML parser - consolidating Blade, Flux, and Livewire components into...

Read more