Introduction to Lines and Words
Learn how to deal with lines or words in Laravel.
We'll cover the following...
In this chapter, we will explore the concepts of lines and words. Both terms are ubiquitous: we see them everywhere but probably don’t give them much thought. We will start with lines.
Press + to interact
<?phpuse Illuminate\Support\Str;Str::macro('lineSplit', function ($value) {return explode("\n", $value);});
When we did this in the previous chapter, we noted that this implementation had some issues. Namely, it does not handle the line-ending types we often encounter. Our current line-splitting implementation only accounts for the \n
(line feed) character, which will work well with text input or documents from UNIX or modern macOS systems. However, there are others.
For ...