Repaire


When building for the web, there are many different ways to limit a string. For example, you could use CSS, JavaScript, or do it through PHP.

Limiting strings is such a common use case that Laravel provides a simple helper to make this easy and I’ve recorded a short video to give you an example walkthrough:

The str_limit is autoloaded and available in both your application code and your views. Here is a simple example demonstrating the default use case. The first parameter is your string and the second is the length you want to trim it too. In this situation seven characters: