Print limited no of characters in Laravel
To print a substring (limited number of characters) in Laravel is very simple. Here is the actual code:
Str::limit($longText, 20)
This will print the first 20 characters of the string stored in the $longText variable.
If you want to concatenate something at the end to indicate that this is not the complete text etc, we can simply pass another parameter to the above function. We can write this as below:
Str::limit($longText, 20, $end= "...") Or Str::limit($longText, 20, $end="read more")
print substring
limited no of text in laravel
A
@ 25/06/2021
© All right reserved 2026